Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. /*****************************************************************************
  3. SOUND_IO.CPP
  4. IO class for RIFF
  5. *****************************************************************************/
  6. #include "../toollib/toollib.h"
  7. #include "tier2/riff.h"
  8. //-----------------------------------------------------------------------------
  9. // Purpose: Implements Audio IO on the engine's COMMON filesystem
  10. //-----------------------------------------------------------------------------
  11. class COM_IOReadBinary : public IFileReadBinary
  12. {
  13. public:
  14. int open( const char *pFileName );
  15. int read( void *pOutput, int size, int file );
  16. void seek( int file, int pos );
  17. unsigned int tell( int file );
  18. unsigned int size( int file );
  19. void close( int file );
  20. };
  21. int COM_IOReadBinary::open( const char *pFileName )
  22. {
  23. int hFile = -1;
  24. _sopen_s( &hFile, pFileName, _O_RDONLY|_O_BINARY, _SH_DENYWR, _S_IREAD );
  25. return hFile;
  26. }
  27. int COM_IOReadBinary::read( void *pOutput, int size, int file )
  28. {
  29. return _read( file, pOutput, size );
  30. }
  31. void COM_IOReadBinary::seek( int file, int pos )
  32. {
  33. _lseek( file, pos, SEEK_SET );
  34. }
  35. unsigned int COM_IOReadBinary::tell( int file )
  36. {
  37. return _lseek( file, 0, SEEK_CUR );
  38. }
  39. unsigned int COM_IOReadBinary::size( int file )
  40. {
  41. long pos;
  42. long length;
  43. pos = _lseek( file, 0, SEEK_CUR );
  44. length = _lseek( file, 0, SEEK_END );
  45. _lseek( file, pos, SEEK_SET );
  46. return length;
  47. }
  48. void COM_IOReadBinary::close( int file )
  49. {
  50. _close( file );
  51. }
  52. static COM_IOReadBinary io;
  53. IFileReadBinary *g_pSndIO = &io;