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.

178 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. cluster.hxx
  5. Abstract:
  6. This class models a chain of clusters in a FAT file system. It gives
  7. the ability to refer to a scattered chain of clusters as one contiguous
  8. region of memory. This memory will be acquired from a MEM object at
  9. initialization.
  10. Author:
  11. Norbert P. Kusters (norbertk) 27-Nov-90
  12. --*/
  13. #if !defined(CLUSTER_CHAIN_DEFN)
  14. #define CLUSTER_CHAIN_DEFN
  15. #include "secrun.hxx"
  16. #include "hmem.hxx"
  17. #if defined ( _AUTOCHECK_ )
  18. #define UFAT_EXPORT
  19. #elif defined ( _UFAT_MEMBER_ )
  20. #define UFAT_EXPORT __declspec(dllexport)
  21. #else
  22. #define UFAT_EXPORT __declspec(dllimport)
  23. #endif
  24. //
  25. // Forward references
  26. //
  27. DECLARE_CLASS( CLUSTER_CHAIN );
  28. DECLARE_CLASS( FAT );
  29. DECLARE_CLASS( FAT_SA );
  30. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  31. DECLARE_CLASS( MEM );
  32. class CLUSTER_CHAIN : public OBJECT {
  33. public:
  34. UFAT_EXPORT
  35. DECLARE_CONSTRUCTOR( CLUSTER_CHAIN );
  36. VIRTUAL
  37. UFAT_EXPORT
  38. ~CLUSTER_CHAIN(
  39. );
  40. NONVIRTUAL
  41. UFAT_EXPORT
  42. BOOLEAN
  43. Initialize(
  44. IN OUT PMEM Mem,
  45. IN OUT PLOG_IO_DP_DRIVE Drive,
  46. IN PFAT_SA FatSuperArea,
  47. IN PCFAT Fat,
  48. IN ULONG ClusterNumber,
  49. IN ULONG LengthOfChain DEFAULT 0
  50. );
  51. VIRTUAL
  52. UFAT_EXPORT
  53. BOOLEAN
  54. Read(
  55. );
  56. VIRTUAL
  57. UFAT_EXPORT
  58. BOOLEAN
  59. Write(
  60. );
  61. NONVIRTUAL
  62. PVOID
  63. GetBuf(
  64. );
  65. NONVIRTUAL
  66. ULONG
  67. QueryLength(
  68. ) CONST;
  69. private:
  70. NONVIRTUAL
  71. VOID
  72. Construct (
  73. );
  74. NONVIRTUAL
  75. VOID
  76. Destroy(
  77. );
  78. PSECRUN* _secruns;
  79. USHORT _num_secruns;
  80. ULONG _length_of_chain;
  81. //
  82. // Stuff needed for compressed volumes.
  83. //
  84. BOOLEAN _is_compressed;
  85. PSECRUN _secrun;
  86. PUCHAR _buf;
  87. HMEM _hmem;
  88. PFAT_SA _fat_sa;
  89. PCFAT _fat;
  90. PLOG_IO_DP_DRIVE
  91. _drive;
  92. ULONG _starting_cluster;
  93. };
  94. INLINE
  95. PVOID
  96. CLUSTER_CHAIN::GetBuf(
  97. )
  98. /*++
  99. Routine Description:
  100. This routine returns a pointer to the beginning of the memory map for
  101. the cluster chain.
  102. Arguments:
  103. None.
  104. Return Value:
  105. A pointer to the beginning of the memory map for the cluster chain.
  106. --*/
  107. {
  108. if (_is_compressed) {
  109. return _buf;
  110. }
  111. return (_secruns && _secruns[0]) ? _secruns[0]->GetBuf() : NULL;
  112. }
  113. INLINE
  114. ULONG
  115. CLUSTER_CHAIN::QueryLength(
  116. ) CONST
  117. /*++
  118. Routine Description:
  119. Computes the number of clusters in the cluster chain.
  120. Arguments:
  121. None.
  122. Return Value:
  123. The number of clusters in the cluster chain.
  124. --*/
  125. {
  126. return _length_of_chain;
  127. }
  128. #endif // CLUSTER_CHAIN_DEFN