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.

209 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1991-2000 Microsoft Corporation
  3. Module Name:
  4. filestrm.hxx
  5. Abstract:
  6. This module contains the declaration for the FILE_STREAM class.
  7. The FILE_STREAM is an abstract class derived from BUFFER_STREAM,
  8. that models a file as a stream of data.
  9. A FILE_STREAM class has the concept of a pointer (file poiter),
  10. and it provides some methods that allow operations on this pointer,
  11. such as:
  12. .move file pointer to a particular position;
  13. .read/write byte in a particular position;
  14. .query the position of the file pointer;
  15. The only way that a client has to create a FILE_STREAM is through
  16. QueryStream() (a method in FSN_FILE).
  17. FILE_STREAM can be has a method for initialization with two different
  18. signatures. In one case, a PFSN_FILE is passed as parameter. This
  19. initialization is used by QueryStream().
  20. The other signature allows that a HANDLE is passed as parameter.
  21. This initialization is used by GetStandardStream() during the
  22. initialization of ulib.
  23. Author:
  24. Jaime Sasson (jaimes) 21-Mar-1991
  25. Environment:
  26. ULIB, User Mode
  27. --*/
  28. #if !defined( _FILE_STREAM_ )
  29. #define _FILE_STREAM_
  30. #include "bufstrm.hxx"
  31. enum SEEKORIGIN {
  32. STREAM_BEGINNING,
  33. STREAM_CURRENT,
  34. STREAM_END
  35. };
  36. //
  37. // Forward references
  38. //
  39. DECLARE_CLASS( FILE_STREAM );
  40. DECLARE_CLASS( FSN_FILE );
  41. class FILE_STREAM : public BUFFER_STREAM {
  42. friend class FSN_FILE;
  43. friend class COMM_DEVICE;
  44. friend PSTREAM GetStandardStream( HANDLE, STREAMACCESS );
  45. public:
  46. ULIB_EXPORT
  47. DECLARE_CAST_MEMBER_FUNCTION( FILE_STREAM );
  48. VIRTUAL
  49. ~FILE_STREAM(
  50. );
  51. VIRTUAL
  52. BOOLEAN
  53. MovePointerPosition(
  54. IN LONGLONG Position,
  55. IN SEEKORIGIN Origin
  56. );
  57. VIRTUAL
  58. STREAMACCESS
  59. QueryAccess(
  60. ) CONST;
  61. VIRTUAL
  62. BOOLEAN
  63. QueryPointerPosition(
  64. OUT PULONGLONG Position
  65. );
  66. NONVIRTUAL
  67. BOOLEAN
  68. Read(
  69. OUT PBYTE Buffer,
  70. IN ULONG NumberOfBytesToRead,
  71. OUT PULONG NumberOfBytesRead
  72. );
  73. NONVIRTUAL
  74. ULIB_EXPORT
  75. BOOLEAN
  76. ReadAt(
  77. OUT PBYTE Buffer,
  78. IN ULONG BytesToRead,
  79. IN LONGLONG Position,
  80. IN SEEKORIGIN Origin,
  81. OUT PULONG BytesRead
  82. );
  83. NONVIRTUAL
  84. BOOLEAN
  85. Write(
  86. IN PCBYTE Buffer,
  87. IN ULONG BytesToWrite,
  88. OUT PULONG BytesWritten
  89. );
  90. NONVIRTUAL
  91. BOOLEAN
  92. WriteAt(
  93. OUT PBYTE Buffer,
  94. IN ULONG BytesToWrite,
  95. IN LONGLONG Position,
  96. IN SEEKORIGIN Origin,
  97. OUT PULONG BytesWritten
  98. );
  99. protected:
  100. DECLARE_CONSTRUCTOR( FILE_STREAM );
  101. NONVIRTUAL
  102. BOOLEAN
  103. Initialize(
  104. PCFSN_FILE File,
  105. STREAMACCESS Access,
  106. DWORD Attributes DEFAULT 0
  107. );
  108. NONVIRTUAL
  109. BOOLEAN
  110. Initialize(
  111. HANDLE Handle,
  112. STREAMACCESS Access
  113. );
  114. VIRTUAL
  115. BOOLEAN
  116. AdvanceBufferPointer(
  117. IN ULONG NumberOfBytes
  118. );
  119. VIRTUAL
  120. BOOLEAN
  121. EndOfFile(
  122. ) CONST;
  123. NONVIRTUAL
  124. BOOLEAN
  125. FillBuffer(
  126. IN PBYTE Buffer,
  127. IN ULONG BufferSize,
  128. OUT PULONG BytesRead
  129. );
  130. NONVIRTUAL
  131. PCBYTE
  132. GetBuffer(
  133. PULONG BytesInBuffer
  134. );
  135. VIRTUAL
  136. HANDLE
  137. QueryHandle(
  138. ) CONST;
  139. private:
  140. NONVIRTUAL
  141. VOID
  142. Construct(
  143. );
  144. HANDLE _FileHandle;
  145. HANDLE _FileMappingHandle;
  146. STREAMACCESS _Access;
  147. BOOLEAN _EndOfFile;
  148. BOOLEAN _ShouldCloseHandle;
  149. PBYTE _FileBaseAddress;
  150. ULONG64 _FileSize;
  151. PBYTE _CurrentByte;
  152. BOOLEAN _EmptyFile;
  153. BOOLEAN _MemoryMappedFile;
  154. };
  155. #endif // _FILE_STREAM_