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.

121 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: CIRCSTOB.HXX
  7. //
  8. // Contents: DownLevel Recoverable Storage Object.
  9. //
  10. // Classes: CiRcovStorageObj
  11. //
  12. // History: 04-Feb-1994 SrikantS Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <prcstob.hxx>
  17. #include <mmstrm.hxx>
  18. #include <cistore.hxx>
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CiRcovStorageObj ()
  22. //
  23. // Purpose: Recoverable Storage Object implementation for the downlevel
  24. // content index.
  25. //
  26. // History: 2-10-94 srikants Created
  27. // 2-13-98 kitmanh Added fReadOnly for CiRcovStorageObj
  28. // constructor
  29. // 2-17-98 kitmanh Added private member _fIsReadOnly
  30. // 27-Oct-98 KLam Added cbDiskSpaceToLeave to constructor
  31. // Added private member _cbDiskSpaceToLeave
  32. //
  33. // Notes:
  34. //
  35. //----------------------------------------------------------------------------
  36. class CiRcovStorageObj : public PRcovStorageObj
  37. {
  38. public:
  39. CiRcovStorageObj( CiStorage & storage,
  40. WCHAR * wcsHdr,
  41. WCHAR * wcsCopy1,
  42. WCHAR * wcsCopy2,
  43. ULONG cbDiskSpaceToLeave,
  44. BOOL fReadOnly);
  45. virtual ~CiRcovStorageObj();
  46. void InithdrStrm() { _hdrStrm.InitFIsReadOnly( _fIsReadOnly ); }
  47. void Open( CRcovStorageHdr::DataCopyNum n, BOOL fWrite );
  48. void Close( CRcovStorageHdr::DataCopyNum n );
  49. PMmStream & GetMmStream( CRcovStorageHdr::DataCopyNum n )
  50. {
  51. return *_apMmStrm[n];
  52. }
  53. BOOL IsOpen( CRcovStorageHdr::DataCopyNum n )
  54. {
  55. return _apMmStrm[n] != NULL;
  56. }
  57. CMmStreamBuf & GetMmStreamBuf( CRcovStorageHdr::DataCopyNum n )
  58. {
  59. Win4Assert( ( CRcovStorageHdr::idxOne == n ) ||
  60. ( CRcovStorageHdr::idxTwo == n ) );
  61. if ( CRcovStorageHdr::idxOne == n )
  62. return _sbufOne;
  63. else
  64. return _sbufTwo;
  65. }
  66. BOOL IsMapped( CRcovStorageHdr::DataCopyNum n )
  67. {
  68. return 0 != GetMmStreamBuf( n ).Get();
  69. }
  70. void AcquireAccess( ExclusionType et ) { }
  71. void ReleaseAccess() { }
  72. void ReadHeader();
  73. void WriteHeader();
  74. BOOL IsReadOnly() { return _fIsReadOnly; }
  75. private:
  76. PMmStream * QueryMmStream( CRcovStorageHdr::DataCopyNum n, BOOL fWritable );
  77. WCHAR * _wcsCopy1;
  78. WCHAR * _wcsCopy2; // Path names of the copy 1 and copy 2
  79. // objects.
  80. CMmStream _hdrStrm;
  81. CMmStreamBuf _hdrSbuf; // Memory mapped stream and buffer for the
  82. // header.
  83. // Memory mapped stream buffers for the
  84. // two copies.
  85. // These two couldn't be an array of unwindable objects due to
  86. // a compiler bug. It's probably fixed by now.
  87. CMmStreamBuf _sbufOne;
  88. CMmStreamBuf _sbufTwo;
  89. PMmStream * _apMmStrm[CRcovStorageHdr::NUMCOPIES];
  90. // Array of the two copies of memory
  91. // mapped streams.
  92. PStorage & _storage;
  93. ULONG _cbDiskSpaceToLeave;
  94. BOOL _fIsReadOnly;
  95. };