Leaked source code of windows server 2003
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.

205 lines
4.9 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: stream.hxx
  7. //
  8. // Contents: Stream header for mstream project
  9. //
  10. // Classes: CSStream - single linear stream for MSF
  11. //
  12. //--------------------------------------------------------------------
  13. #ifndef __STREAM_HXX__
  14. #define __STREAM_HXX__
  15. #include "msf.hxx"
  16. #include "handle.hxx"
  17. #include "entry.hxx"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Class: CStreamCache (stmc)
  21. //
  22. // Purpose: Cache for stream optimization
  23. //
  24. // Interface: See below.
  25. //
  26. //----------------------------------------------------------------------------
  27. class CStreamCache
  28. {
  29. public:
  30. inline CStreamCache();
  31. inline void SetCache(ULONG ulOffset, SECT sect);
  32. inline ULONG GetOffset(void) const;
  33. inline SECT GetSect(void) const;
  34. private:
  35. ULONG _ulOffset;
  36. SECT _sect;
  37. };
  38. //+---------------------------------------------------------------------------
  39. //
  40. // Member: CStreamCache::CStreamCache, public
  41. //
  42. // Synopsis: CStreamCache constructor
  43. //
  44. //----------------------------------------------------------------------------
  45. inline CStreamCache::CStreamCache()
  46. {
  47. _ulOffset = MAX_ULONG;
  48. _sect = ENDOFCHAIN;
  49. }
  50. //+---------------------------------------------------------------------------
  51. //
  52. // Member: CStreamCache::SetCache, public
  53. //
  54. // Synopsis: Set the cache information
  55. //
  56. // Arguments: [ulOffset] -- Offset into chain
  57. // [sect] -- Sect at that offset
  58. //
  59. //----------------------------------------------------------------------------
  60. inline void CStreamCache::SetCache(ULONG ulOffset, SECT sect)
  61. {
  62. _ulOffset = ulOffset;
  63. _sect = sect;
  64. }
  65. //+---------------------------------------------------------------------------
  66. //
  67. // Member: CStreamCache::GetOffset, public
  68. //
  69. // Synopsis: Return offset
  70. //
  71. //----------------------------------------------------------------------------
  72. inline ULONG CStreamCache::GetOffset(void) const
  73. {
  74. return _ulOffset;
  75. }
  76. //+---------------------------------------------------------------------------
  77. //
  78. // Member: CStreamCache::GetSect, public
  79. //
  80. // Synopsis: Return sect
  81. //
  82. //----------------------------------------------------------------------------
  83. inline SECT CStreamCache::GetSect(void) const
  84. {
  85. return _sect;
  86. }
  87. //+----------------------------------------------------------------------
  88. //
  89. // Class: CDirectStream (ds)
  90. //
  91. // Purpose: Direct stream class
  92. //
  93. // Notes:
  94. //
  95. //-----------------------------------------------------------------------
  96. class CDirectStream: public PEntry
  97. {
  98. public:
  99. CDirectStream(DFLUID dl);
  100. void InitSystem( CMStream *pms,
  101. SID sid,
  102. ULONGLONG cbSize);
  103. SCODE Init( CStgHandle *pstgh,
  104. CDfName const *pdfn,
  105. BOOL const fCreate);
  106. ~CDirectStream();
  107. void AddRef(VOID);
  108. inline void DecRef(VOID);
  109. void Release(VOID);
  110. SCODE ReadAt( ULONGLONG ulOffset,
  111. VOID HUGEP *pBuffer,
  112. ULONG ulCount,
  113. ULONG STACKBASED *pulRetval);
  114. SCODE WriteAt( ULONGLONG ulOffset,
  115. VOID const HUGEP *pBuffer,
  116. ULONG ulCount,
  117. ULONG STACKBASED *pulRetval);
  118. SCODE SetSize(ULONGLONG ulNewSize);
  119. void GetSize(ULONGLONG *pulSize);
  120. // PEntry
  121. virtual SCODE GetTime(WHICHTIME wt, TIME_T *ptm);
  122. virtual SCODE SetTime(WHICHTIME wt, TIME_T tm);
  123. inline CStmHandle *GetHandle(void);
  124. private:
  125. CStmHandle _stmh;
  126. CStreamCache _stmc;
  127. ULONGLONG _ulSize;
  128. ULONGLONG _ulOldSize;
  129. LONG _cReferences;
  130. #ifdef _MSC_VER
  131. #pragma warning(disable:4512)
  132. // default assignment operator could not be generated since we have a const
  133. // member variable (of PEntry). This is okay since we are not using
  134. // the assignment operator anyway.
  135. #endif // MSC_VER
  136. };
  137. #ifdef _MSC_VER
  138. #pragma warning(default:4512)
  139. #endif // _MSC_VER
  140. //+---------------------------------------------------------------------------
  141. //
  142. // Member: CDirectStream::GetHandle, public
  143. //
  144. // Synopsis: Returns a pointer to the stream handle
  145. //
  146. //----------------------------------------------------------------------------
  147. inline CStmHandle *CDirectStream::GetHandle(void)
  148. {
  149. return &_stmh;
  150. }
  151. //+---------------------------------------------------------------------------
  152. //
  153. // Member: CDirectStream::DecRef, public
  154. //
  155. // Synopsis: Decrements the ref count
  156. //
  157. //----------------------------------------------------------------------------
  158. inline void CDirectStream::DecRef(void)
  159. {
  160. AtomicDec(&_cReferences);
  161. }
  162. #endif //__SSTREAM_HXX__