summaryrefslogtreecommitdiff
path: root/utils/xbox/MakeGameData/sound_io.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/xbox/MakeGameData/sound_io.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/xbox/MakeGameData/sound_io.cpp')
-rw-r--r--utils/xbox/MakeGameData/sound_io.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/utils/xbox/MakeGameData/sound_io.cpp b/utils/xbox/MakeGameData/sound_io.cpp
new file mode 100644
index 0000000..44e0323
--- /dev/null
+++ b/utils/xbox/MakeGameData/sound_io.cpp
@@ -0,0 +1,68 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+/*****************************************************************************
+ SOUND_IO.CPP
+
+ IO class for RIFF
+*****************************************************************************/
+#include "../toollib/toollib.h"
+#include "tier2/riff.h"
+
+//-----------------------------------------------------------------------------
+// Purpose: Implements Audio IO on the engine's COMMON filesystem
+//-----------------------------------------------------------------------------
+class COM_IOReadBinary : public IFileReadBinary
+{
+public:
+ int open( const char *pFileName );
+ int read( void *pOutput, int size, int file );
+ void seek( int file, int pos );
+ unsigned int tell( int file );
+ unsigned int size( int file );
+ void close( int file );
+};
+
+
+int COM_IOReadBinary::open( const char *pFileName )
+{
+ int hFile = -1;
+
+ _sopen_s( &hFile, pFileName, _O_RDONLY|_O_BINARY, _SH_DENYWR, _S_IREAD );
+
+ return hFile;
+}
+
+int COM_IOReadBinary::read( void *pOutput, int size, int file )
+{
+ return _read( file, pOutput, size );
+}
+
+void COM_IOReadBinary::seek( int file, int pos )
+{
+ _lseek( file, pos, SEEK_SET );
+}
+
+unsigned int COM_IOReadBinary::tell( int file )
+{
+ return _lseek( file, 0, SEEK_CUR );
+}
+
+unsigned int COM_IOReadBinary::size( int file )
+{
+ long pos;
+ long length;
+
+ pos = _lseek( file, 0, SEEK_CUR );
+ length = _lseek( file, 0, SEEK_END );
+ _lseek( file, pos, SEEK_SET );
+
+ return length;
+}
+
+void COM_IOReadBinary::close( int file )
+{
+ _close( file );
+}
+
+static COM_IOReadBinary io;
+IFileReadBinary *g_pSndIO = &io;
+