Source code of Windows XP (NT5)
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.

87 lines
2.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: FSTREAM.HXX
  6. //
  7. // Contents: Streams for accessing files w/runtime libs
  8. //
  9. // Classes: CStreamFile
  10. //
  11. // History: 05-Aug-92 MikeHew Created
  12. // 14-Aug-92 KyleP Hacked
  13. // 23-Nov-92 AmyA Revised for buffering data
  14. //
  15. //----------------------------------------------------------------------------
  16. #ifndef __FSTREAM_HXX__
  17. #define __FSTREAM_HXX__
  18. #ifdef DISPLAY_INCLUDES
  19. #pragma message( "#include <" __FILE__ ">..." )
  20. #endif
  21. #include <except.hxx>
  22. #include <streams.hxx>
  23. #include <stdio.h>
  24. #include <debnot.h> // for Win4Assert
  25. #define defaultBufSize 4096
  26. //+---------------------------------------------------------------------------
  27. //
  28. // Class: CStreamFile
  29. //
  30. // Purpose: Stream for dumping data to a file and reading back
  31. //
  32. // History: 29-Jul-92 MikeHew Created
  33. // 23-Nov-92 AmyA Revised for buffering data
  34. //
  35. // Notes: Seek() is from the current offset
  36. //
  37. //----------------------------------------------------------------------------
  38. class CStreamFile : INHERIT_VIRTUAL_UNWIND, public CStreamA
  39. {
  40. DECLARE_UNWIND
  41. public:
  42. enum FileType
  43. {
  44. NewFile,
  45. NewOrExistingFile,
  46. ExistingFile
  47. };
  48. EXPORTDEF CStreamFile( const char * filename, FileType type );
  49. EXPORTDEF ~CStreamFile();
  50. //
  51. // Status functions
  52. //
  53. BOOL Ok() { return (_fp != 0) && !ferror( _fp ); }
  54. //
  55. // Input from stream functions
  56. //
  57. EXPORTDEF unsigned APINOT Read( void *dest, unsigned size );
  58. //
  59. // Output to stream functions
  60. //
  61. EXPORTDEF unsigned APINOT Write( const void *source, unsigned size );
  62. //
  63. // Misc
  64. //
  65. EXPORTDEF int APINOT Seek( LONG offset, CStream::SEEK origin = CStream::SET );
  66. ULONG Size();
  67. private:
  68. BOOL FillBuf();
  69. FILE * _fp;
  70. };
  71. #endif // __FSTREAM_HXX__