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.

249 lines
5.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1999.
  5. //
  6. // File: FFEnum.hxx
  7. //
  8. // Contents: Enumerate NTQueryDirectory results
  9. //
  10. // History: 28-Oct-93 KyleP Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. //+-------------------------------------------------------------------------
  15. //
  16. // Class: CDirEntry
  17. //
  18. // Purpose: OFS directory entry (stat buffer)
  19. //
  20. // History: 17-May-93 KyleP Created
  21. //
  22. // Notes: ENTERING CASTING (It's not my structure but I need to
  23. // use it.)
  24. //
  25. // There are two forms of directory entry, depending on whether
  26. // a short (8.3) name exists for a file. The structure is
  27. // either:
  28. //
  29. // USHORT cbKey;
  30. // USHORT cbData;
  31. // DSKDIRINFOLONG ddil;
  32. // BYTE bKey[];
  33. //
  34. // or:
  35. //
  36. // USHORT cbKey;
  37. // USHORT cbData;
  38. // DSKDIRINFOLONG ddil;
  39. // WCHAR wcShortName[12]
  40. // BYTE bKey[];
  41. //
  42. // If cbData == sizeof(DSKDIRINFOLONG) then the first form
  43. // is used.
  44. //
  45. //
  46. //--------------------------------------------------------------------------
  47. class CDirEntry : private _FILE_BOTH_DIR_INFORMATION
  48. {
  49. public:
  50. //
  51. // Access
  52. //
  53. inline USHORT FilenameSize() const;
  54. inline WCHAR const * Filename() const;
  55. inline USHORT ShortNameSize() const;
  56. inline WCHAR const * ShortName() const;
  57. inline LONGLONG const & CreateTime() const;
  58. inline LONGLONG const & ModifyTime() const;
  59. inline LONGLONG const & AccessTime() const;
  60. inline LONGLONG const & ChangeTime() const;
  61. inline LONGLONG const & ObjectSize() const;
  62. inline ULONG Attributes() const;
  63. inline WORKID WorkId() const;
  64. inline FILETIME const & CreateTimeAsFILETIME() const;
  65. inline FILETIME const & ModifyTimeAsFILETIME() const;
  66. inline FILETIME const & AccessTimeAsFILETIME() const;
  67. inline FILETIME const & ChangeTimeAsFILETIME() const;
  68. //
  69. // Modification
  70. //
  71. inline void SetAttributes( ULONG ulAttr );
  72. //
  73. // Traversal
  74. //
  75. inline CDirEntry * Next() const;
  76. private:
  77. inline ULONG _EntrySize();
  78. };
  79. inline USHORT CDirEntry::FilenameSize() const
  80. {
  81. return( (USHORT)FileNameLength );
  82. }
  83. inline WCHAR const * CDirEntry::Filename() const
  84. {
  85. return( &FileName[0] );
  86. }
  87. inline USHORT CDirEntry::ShortNameSize() const
  88. {
  89. if ( 0 == ShortNameLength )
  90. return (USHORT)FileNameLength;
  91. else
  92. return (USHORT)ShortNameLength;
  93. }
  94. inline WCHAR const * CDirEntry::ShortName() const
  95. {
  96. if ( 0 == ShortNameLength )
  97. return &FileName[0];
  98. else
  99. return &_FILE_BOTH_DIR_INFORMATION::ShortName[0];
  100. }
  101. inline LONGLONG const & CDirEntry::CreateTime() const
  102. {
  103. return( CreationTime.QuadPart );
  104. }
  105. inline LONGLONG const & CDirEntry::ModifyTime() const
  106. {
  107. return( LastWriteTime.QuadPart );
  108. }
  109. inline LONGLONG const & CDirEntry::AccessTime() const
  110. {
  111. return( LastAccessTime.QuadPart );
  112. }
  113. inline LONGLONG const & CDirEntry::ChangeTime() const
  114. {
  115. return _FILE_BOTH_DIR_INFORMATION::ChangeTime.QuadPart;
  116. }
  117. inline LONGLONG const & CDirEntry::ObjectSize() const
  118. {
  119. return( EndOfFile.QuadPart );
  120. }
  121. inline ULONG CDirEntry::Attributes() const
  122. {
  123. return( FileAttributes );
  124. }
  125. inline WORKID CDirEntry::WorkId() const
  126. {
  127. return( FileIndex );
  128. }
  129. inline FILETIME const & CDirEntry::CreateTimeAsFILETIME() const
  130. {
  131. return( *(FILETIME *)&CreationTime.QuadPart );
  132. }
  133. inline FILETIME const & CDirEntry::ModifyTimeAsFILETIME() const
  134. {
  135. return( *(FILETIME *)&LastWriteTime.QuadPart );
  136. }
  137. inline FILETIME const & CDirEntry::AccessTimeAsFILETIME() const
  138. {
  139. return( *(FILETIME *)&LastAccessTime.QuadPart );
  140. }
  141. inline FILETIME const & CDirEntry::ChangeTimeAsFILETIME() const
  142. {
  143. return( *(FILETIME *)&_FILE_BOTH_DIR_INFORMATION::ChangeTime.QuadPart );
  144. }
  145. inline void CDirEntry::SetAttributes( ULONG ulAttr )
  146. {
  147. FileAttributes = ulAttr;
  148. }
  149. inline CDirEntry * CDirEntry::Next() const
  150. {
  151. //
  152. // All entries are DWord aligned
  153. //
  154. if ( NextEntryOffset != 0 )
  155. return( (CDirEntry *)( ((BYTE *)this) + NextEntryOffset ));
  156. else
  157. return( 0 );
  158. }
  159. //+-------------------------------------------------------------------------
  160. //
  161. // Class: CDirNotifyEntry
  162. //
  163. // Purpose: NtChangeNotifyDirectory entry
  164. //
  165. // History: 03-May-94 KyleP Created
  166. //
  167. // Notes: ENTERING CASTING (It's not my structure but I need to
  168. // use it.)
  169. //
  170. //--------------------------------------------------------------------------
  171. class CDirNotifyEntry : protected _FILE_NOTIFY_INFORMATION
  172. {
  173. public:
  174. inline USHORT PathSize() const;
  175. inline WCHAR const * Path() const;
  176. inline ULONG Change() const;
  177. inline CDirNotifyEntry const * Next() const;
  178. };
  179. inline USHORT CDirNotifyEntry::PathSize() const
  180. {
  181. // check for uninitialized memory
  182. Win4Assert( 0xdddddddd != FileNameLength );
  183. return( (USHORT)FileNameLength );
  184. }
  185. inline WCHAR const * CDirNotifyEntry::Path() const
  186. {
  187. return( &FileName[0] );
  188. }
  189. inline ULONG CDirNotifyEntry::Change() const
  190. {
  191. return( Action );
  192. }
  193. inline CDirNotifyEntry const * CDirNotifyEntry::Next() const
  194. {
  195. //
  196. // All entries are DWord aligned
  197. //
  198. if ( NextEntryOffset != 0 )
  199. {
  200. // check for uninitialized memory
  201. Win4Assert( 0xdddddddd != NextEntryOffset );
  202. return( (CDirNotifyEntry *)( ((BYTE *)this) + NextEntryOffset ));
  203. }
  204. else
  205. {
  206. return( 0 );
  207. }
  208. }