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.

80 lines
1.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997, Microsoft Corporation.
  4. //
  5. // File: mmistrm.hxx
  6. //
  7. // Contents: Memory Mapped IStream
  8. //
  9. // Classes: CMmIStream
  10. //
  11. // History: 11-Feb-97 KyleP Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #pragma once
  15. #include <pmmstrm.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Class: CMmIStream
  19. //
  20. // Purpose: Memory Mapped Stream, based on IStream
  21. //
  22. // History: 11-Feb-97 KyleP Created
  23. //
  24. //----------------------------------------------------------------------------
  25. class CMmIStream: INHERIT_VIRTUAL_UNWIND, public PMmStream
  26. {
  27. friend class CMmStreamBuf;
  28. INLINE_UNWIND(CMmIStream)
  29. public:
  30. CMmIStream();
  31. BOOL Ok() { return _pStream != 0; }
  32. virtual ~CMmIStream();
  33. void Open( IStream * pStream );
  34. void Close();
  35. void SetSize( PStorage& storage, ULONG newSizeLow, ULONG newSizeHigh ) {}
  36. BOOL isEmpty() { return _statstg.cbSize.HighPart == 0 && _statstg.cbSize.LowPart == 0; }
  37. ULONG SizeLow() { return _statstg.cbSize.LowPart; }
  38. ULONG SizeHigh() { return _statstg.cbSize.HighPart; }
  39. LONGLONG Size() { return _statstg.cbSize.QuadPart; }
  40. BOOL isWritable() { return FALSE; }
  41. void MapAll ( CMmStreamBuf& sbuf );
  42. void Map ( CMmStreamBuf& sbuf,
  43. ULONG cb = 0,
  44. ULONG offLow = 0,
  45. ULONG offHigh = 0,
  46. BOOL fMapForWrite = FALSE );
  47. void Unmap ( CMmStreamBuf& sbuf );
  48. void Flush ( CMmStreamBuf& sbuf, ULONG cb, BOOL fThrowOnFailure = TRUE );
  49. void FlushMetaData ( BOOL fThrowOnFailure = TRUE );
  50. protected:
  51. IStream * _pStream; // Stream
  52. BYTE * _pBuf; // Stream is 'mapped' (buffered) here
  53. STATSTG _statstg; // Stream size, etc.
  54. };