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.

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