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.

264 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. filedir.hxx
  5. Abstract:
  6. This class is an implementation of FATDIR for all FAT directories
  7. that are implemented as files. In other words all FAT directories
  8. besides the root directory.
  9. --*/
  10. #if !defined(FILEDIR_DEFN)
  11. #define FILEDIR_DEFN
  12. #include "cluster.hxx"
  13. #include "drive.hxx"
  14. #include "fatdir.hxx"
  15. #include "mem.hxx"
  16. #if defined ( _AUTOCHECK_ ) || defined( _EFICHECK_ )
  17. #define UFAT_EXPORT
  18. #elif defined ( _UFAT_MEMBER_ )
  19. #define UFAT_EXPORT __declspec(dllexport)
  20. #else
  21. #define UFAT_EXPORT __declspec(dllimport)
  22. #endif
  23. //
  24. // Forward references
  25. //
  26. DECLARE_CLASS( FAT );
  27. DECLARE_CLASS( FAT_SA );
  28. DECLARE_CLASS( FILEDIR );
  29. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  30. class FILEDIR : public FATDIR {
  31. public:
  32. UFAT_EXPORT
  33. DECLARE_CONSTRUCTOR( FILEDIR );
  34. VIRTUAL
  35. UFAT_EXPORT
  36. ~FILEDIR(
  37. );
  38. NONVIRTUAL
  39. UFAT_EXPORT
  40. BOOLEAN
  41. Initialize(
  42. IN OUT PMEM Mem,
  43. IN OUT PLOG_IO_DP_DRIVE Drive,
  44. IN PFAT_SA FatSuperArea,
  45. IN PCFAT Fat,
  46. IN ULONG StartingCluster
  47. );
  48. NONVIRTUAL
  49. BOOLEAN
  50. Read(
  51. );
  52. NONVIRTUAL
  53. BOOLEAN
  54. Write(
  55. );
  56. NONVIRTUAL
  57. PVOID
  58. GetDirEntry(
  59. IN LONG EntryNumber
  60. );
  61. NONVIRTUAL
  62. ULONG
  63. QueryLength(
  64. ) CONST;
  65. NONVIRTUAL
  66. ULONG
  67. QueryStartingCluster(
  68. );
  69. NONVIRTUAL
  70. LONG
  71. QueryNumberOfEntries(
  72. );
  73. private:
  74. NONVIRTUAL
  75. VOID
  76. Construct (
  77. );
  78. NONVIRTUAL
  79. VOID
  80. Destroy(
  81. );
  82. CLUSTER_CHAIN _cluster;
  83. LONG _number_of_entries;
  84. ULONG _starting_cluster;
  85. };
  86. INLINE
  87. BOOLEAN
  88. FILEDIR::Read(
  89. )
  90. /*++
  91. Routine Description:
  92. This routine reads the directory in from disk.
  93. Arguments:
  94. None.
  95. Return Value:
  96. FALSE - Failure.
  97. TRUE - Success.
  98. --*/
  99. {
  100. return _cluster.Read();
  101. }
  102. INLINE
  103. BOOLEAN
  104. FILEDIR::Write(
  105. )
  106. /*++
  107. Routine Description:
  108. This routine writes the directory to disk.
  109. Arguments:
  110. None.
  111. Return Value:
  112. FALSE - Failure.
  113. TRUE - Success.
  114. --*/
  115. {
  116. return _cluster.Write();
  117. }
  118. INLINE
  119. PVOID
  120. FILEDIR::GetDirEntry(
  121. IN LONG EntryNumber
  122. )
  123. /*++
  124. Routine Description:
  125. This routine returns a pointer to the beginning of the requested
  126. directory entry. The data may then be interpreted with a fat
  127. directory entry object. The return value will be NULL if a request
  128. for a directory entry is beyond the size of the directory.
  129. Arguments:
  130. EntryNumber - The desired entry number. The entries will be numbered
  131. 0, 1, 2, ... , n-1.
  132. Return Value:
  133. A pointer to the beginning of a directory entry or NULL.
  134. --*/
  135. {
  136. return (EntryNumber < _number_of_entries) ?
  137. (PCHAR) _cluster.GetBuf() + BytesPerDirent*EntryNumber : NULL;
  138. }
  139. INLINE
  140. ULONG
  141. FILEDIR::QueryLength(
  142. ) CONST
  143. /*++
  144. Routine Description:
  145. This routine returns the number of clusters in the underlying cluster
  146. chain.
  147. Arguments:
  148. None.
  149. Return Value:
  150. The number of clusters in the cluster chain.
  151. --*/
  152. {
  153. return _cluster.QueryLength();
  154. }
  155. INLINE
  156. ULONG
  157. FILEDIR::QueryStartingCluster(
  158. )
  159. /*++
  160. Routine Description:
  161. This routine returns the starting cluster of the directory.
  162. Arguments:
  163. None.
  164. Return Value:
  165. The starting cluster of the directory.
  166. --*/
  167. {
  168. return _starting_cluster;
  169. }
  170. INLINE
  171. LONG
  172. FILEDIR::QueryNumberOfEntries(
  173. )
  174. /*++
  175. Routine Description:
  176. This routine returns the number of entries in the directory.
  177. Arguments:
  178. None.
  179. Return Value:
  180. The number of entries in the directory.
  181. --*/
  182. {
  183. return _number_of_entries;
  184. }
  185. #endif // FILEDIR_DEFN