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.

110 lines
2.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: cache.hxx
  7. //
  8. // Contents: Stream cache code
  9. //
  10. // Classes: CStreamCache
  11. //
  12. // Functions:
  13. //
  14. // History: 26-May-93 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __CACHE_HXX__
  18. #define __CACHE_HXX__
  19. class CDirectStream;
  20. class CDirectory;
  21. class CFat;
  22. #define CACHESIZE 9
  23. struct SCacheEntry
  24. {
  25. ULONG ulOffset;
  26. SECT sect;
  27. ULONG ulRunLength;
  28. inline SCacheEntry();
  29. };
  30. inline SCacheEntry::SCacheEntry()
  31. {
  32. ulOffset = MAX_ULONG;
  33. sect = ENDOFCHAIN;
  34. ulRunLength = 0;
  35. }
  36. SAFE_DFBASED_PTR(CBasedDirectStreamPtr, CDirectStream);
  37. //+---------------------------------------------------------------------------
  38. //
  39. // Class: CStreamCache (stmc)
  40. //
  41. // Purpose: Cache for stream optimization
  42. //
  43. // Interface: See below.
  44. //
  45. // History: 14-Dec-92 PhilipLa Created
  46. //
  47. //----------------------------------------------------------------------------
  48. class CStreamCache
  49. {
  50. public:
  51. CStreamCache();
  52. ~CStreamCache();
  53. void Init(CMStream *pmsParent, SID sid, CDirectStream *pds);
  54. void Empty(void);
  55. SCODE GetSect(ULONG ulOffset, SECT *psect);
  56. SCODE GetESect(ULONG ulOffset, SECT *psect);
  57. SCODE EmptyRegion(ULONG oStart, ULONG oEnd);
  58. SCODE Allocate(CFat *pfat, ULONG cSect, SECT *psectStart);
  59. SCODE Contig(
  60. ULONG ulOffset,
  61. BOOL fWrite,
  62. SSegment STACKBASED *aseg,
  63. ULONG ulLength,
  64. ULONG *pcSeg);
  65. private:
  66. inline CDirectory *GetDir(void);
  67. inline CFat * GetFat(void);
  68. inline CFat * GetMiniFat(void);
  69. #ifdef LARGE_STREAMS
  70. inline ULONGLONG GetSize(void);
  71. #else
  72. inline ULONG GetSize(void);
  73. #endif
  74. inline SID GetSid(void);
  75. inline CFat * SelectFat(void);
  76. SCODE GetStart(SECT *psectStart);
  77. inline BOOL CheckSegment(ULONG ulOffset,
  78. SCacheEntry sce,
  79. ULONG *pulCount,
  80. SECT *psectCache,
  81. ULONG *pulCacheOffset);
  82. void CacheSegment(SSegment *pseg);
  83. SCacheEntry _ase[CACHESIZE];
  84. CBasedDirectStreamPtr _pds;
  85. CBasedMStreamPtr _pmsParent;
  86. SID _sid;
  87. USHORT _uHighCacheIndex;
  88. USHORT _uNextCacheIndex;
  89. USHORT _uCacheState;
  90. };
  91. #endif // #ifndef __CACHE_HXX__