25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

473 lines
31 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System;
  22. using System.Collections.Generic;
  23. using System.IO;
  24. using System.Security;
  25. using SearchOption = System.IO.SearchOption;
  26. namespace Alphaleonis.Win32.Filesystem
  27. {
  28. partial class Directory
  29. {
  30. #region .NET
  31. /// <summary>Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  32. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  33. /// <exception cref="ArgumentException"/>
  34. /// <exception cref="ArgumentNullException"/>
  35. /// <exception cref="DirectoryNotFoundException"/>
  36. /// <exception cref="IOException"/>
  37. /// <exception cref="NotSupportedException"/>
  38. /// <exception cref="UnauthorizedAccessException"/>
  39. /// <param name="path">The directory to search.</param>
  40. [SecurityCritical]
  41. public static IEnumerable<string> EnumerateFileSystemEntries(string path)
  42. {
  43. return EnumerateFileSystemEntryInfosCore<string>(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
  44. }
  45. /// <summary>Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  46. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  47. /// <exception cref="ArgumentException"/>
  48. /// <exception cref="ArgumentNullException"/>
  49. /// <exception cref="DirectoryNotFoundException"/>
  50. /// <exception cref="IOException"/>
  51. /// <exception cref="NotSupportedException"/>
  52. /// <exception cref="UnauthorizedAccessException"/>
  53. /// <param name="path">The directory to search.</param>
  54. /// <param name="searchPattern">
  55. /// The search string to match against the names of directories in <paramref name="path"/>.
  56. /// This parameter can contain a combination of valid literal path and wildcard
  57. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  58. /// </param>
  59. [SecurityCritical]
  60. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern)
  61. {
  62. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
  63. }
  64. /// <summary>Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>, and optionally searches subdirectories.</summary>
  65. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/> and <paramref name="searchOption"/>.</returns>
  66. /// <exception cref="ArgumentException"/>
  67. /// <exception cref="ArgumentNullException"/>
  68. /// <exception cref="DirectoryNotFoundException"/>
  69. /// <exception cref="IOException"/>
  70. /// <exception cref="NotSupportedException"/>
  71. /// <exception cref="UnauthorizedAccessException"/>
  72. /// <param name="path">The directory to search.</param>
  73. /// <param name="searchPattern">
  74. /// The search string to match against the names of directories in <paramref name="path"/>.
  75. /// This parameter can contain a combination of valid literal path and wildcard
  76. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  77. /// </param>
  78. /// <param name="searchOption">
  79. /// One of the <see cref="SearchOption"/> enumeration values that specifies whether the <paramref name="searchOption"/>
  80. /// should include only the current directory or should include all subdirectories.
  81. /// </param>
  82. [SecurityCritical]
  83. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
  84. {
  85. var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
  86. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, options, PathFormat.RelativePath);
  87. }
  88. #endregion // .NET
  89. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  90. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  91. /// <exception cref="ArgumentException"/>
  92. /// <exception cref="ArgumentNullException"/>
  93. /// <exception cref="DirectoryNotFoundException"/>
  94. /// <exception cref="IOException"/>
  95. /// <exception cref="NotSupportedException"/>
  96. /// <exception cref="UnauthorizedAccessException"/>
  97. /// <param name="path">The directory to search.</param>
  98. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  99. [SecurityCritical]
  100. public static IEnumerable<string> EnumerateFileSystemEntries(string path, PathFormat pathFormat)
  101. {
  102. return EnumerateFileSystemEntryInfosCore<string>(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
  103. }
  104. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  105. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  106. /// <exception cref="ArgumentException"/>
  107. /// <exception cref="ArgumentNullException"/>
  108. /// <exception cref="DirectoryNotFoundException"/>
  109. /// <exception cref="IOException"/>
  110. /// <exception cref="NotSupportedException"/>
  111. /// <exception cref="UnauthorizedAccessException"/>
  112. /// <param name="path">The directory to search.</param>
  113. /// <param name="searchPattern">
  114. /// The search string to match against the names of directories in <paramref name="path"/>.
  115. /// This parameter can contain a combination of valid literal path and wildcard
  116. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  117. /// </param>
  118. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  119. [SecurityCritical]
  120. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, PathFormat pathFormat)
  121. {
  122. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
  123. }
  124. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>, and optionally searches subdirectories.</summary>
  125. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/> and <paramref name="searchOption"/>.</returns>
  126. /// <exception cref="ArgumentException"/>
  127. /// <exception cref="ArgumentNullException"/>
  128. /// <exception cref="DirectoryNotFoundException"/>
  129. /// <exception cref="IOException"/>
  130. /// <exception cref="NotSupportedException"/>
  131. /// <exception cref="UnauthorizedAccessException"/>
  132. /// <param name="path">The directory to search.</param>
  133. /// <param name="searchPattern">
  134. /// The search string to match against the names of directories in <paramref name="path"/>.
  135. /// This parameter can contain a combination of valid literal path and wildcard
  136. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  137. /// </param>
  138. /// <param name="searchOption">
  139. /// One of the <see cref="SearchOption"/> enumeration values that specifies whether the <paramref name="searchOption"/>
  140. /// should include only the current directory or should include all subdirectories.
  141. /// </param>
  142. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  143. [SecurityCritical]
  144. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
  145. {
  146. var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
  147. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, options, pathFormat);
  148. }
  149. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  150. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  151. /// <exception cref="ArgumentException"/>
  152. /// <exception cref="ArgumentNullException"/>
  153. /// <exception cref="DirectoryNotFoundException"/>
  154. /// <exception cref="IOException"/>
  155. /// <exception cref="NotSupportedException"/>
  156. /// <exception cref="UnauthorizedAccessException"/>
  157. /// <param name="path">The directory to search.</param>
  158. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  159. [SecurityCritical]
  160. public static IEnumerable<string> EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options)
  161. {
  162. return EnumerateFileSystemEntryInfosCore<string>(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
  163. }
  164. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  165. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  166. /// <exception cref="ArgumentException"/>
  167. /// <exception cref="ArgumentNullException"/>
  168. /// <exception cref="DirectoryNotFoundException"/>
  169. /// <exception cref="IOException"/>
  170. /// <exception cref="NotSupportedException"/>
  171. /// <exception cref="UnauthorizedAccessException"/>
  172. /// <param name="path">The directory to search.</param>
  173. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  174. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  175. [SecurityCritical]
  176. public static IEnumerable<string> EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
  177. {
  178. return EnumerateFileSystemEntryInfosCore<string>(null, path, Path.WildcardStarMatchAll, options, pathFormat);
  179. }
  180. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  181. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  182. /// <exception cref="ArgumentException"/>
  183. /// <exception cref="ArgumentNullException"/>
  184. /// <exception cref="DirectoryNotFoundException"/>
  185. /// <exception cref="IOException"/>
  186. /// <exception cref="NotSupportedException"/>
  187. /// <exception cref="UnauthorizedAccessException"/>
  188. /// <param name="path">The directory to search.</param>
  189. /// <param name="searchPattern">
  190. /// The search string to match against the names of directories in <paramref name="path"/>.
  191. /// This parameter can contain a combination of valid literal path and wildcard
  192. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  193. /// </param>
  194. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  195. [SecurityCritical]
  196. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options)
  197. {
  198. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, options, PathFormat.RelativePath);
  199. }
  200. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  201. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  202. /// <exception cref="ArgumentException"/>
  203. /// <exception cref="ArgumentNullException"/>
  204. /// <exception cref="DirectoryNotFoundException"/>
  205. /// <exception cref="IOException"/>
  206. /// <exception cref="NotSupportedException"/>
  207. /// <exception cref="UnauthorizedAccessException"/>
  208. /// <param name="path">The directory to search.</param>
  209. /// <param name="searchPattern">
  210. /// The search string to match against the names of directories in <paramref name="path"/>.
  211. /// This parameter can contain a combination of valid literal path and wildcard
  212. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  213. /// </param>
  214. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  215. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  216. [SecurityCritical]
  217. public static IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
  218. {
  219. return EnumerateFileSystemEntryInfosCore<string>(null, path, searchPattern, options, pathFormat);
  220. }
  221. #region Transactional
  222. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  223. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  224. /// <exception cref="ArgumentException"/>
  225. /// <exception cref="ArgumentNullException"/>
  226. /// <exception cref="DirectoryNotFoundException"/>
  227. /// <exception cref="IOException"/>
  228. /// <exception cref="NotSupportedException"/>
  229. /// <exception cref="UnauthorizedAccessException"/>
  230. /// <param name="transaction">The transaction.</param>
  231. /// <param name="path">The directory to search.</param>
  232. [SecurityCritical]
  233. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path)
  234. {
  235. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
  236. }
  237. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  238. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  239. /// <exception cref="ArgumentException"/>
  240. /// <exception cref="ArgumentNullException"/>
  241. /// <exception cref="DirectoryNotFoundException"/>
  242. /// <exception cref="IOException"/>
  243. /// <exception cref="NotSupportedException"/>
  244. /// <exception cref="UnauthorizedAccessException"/>
  245. /// <param name="transaction">The transaction.</param>
  246. /// <param name="path">The directory to search.</param>
  247. /// <param name="searchPattern">
  248. /// The search string to match against the names of directories in <paramref name="path"/>.
  249. /// This parameter can contain a combination of valid literal path and wildcard
  250. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  251. /// </param>
  252. [SecurityCritical]
  253. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern)
  254. {
  255. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
  256. }
  257. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>, and optionally searches subdirectories.</summary>
  258. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/> and <paramref name="searchOption"/>.</returns>
  259. /// <exception cref="ArgumentException"/>
  260. /// <exception cref="ArgumentNullException"/>
  261. /// <exception cref="DirectoryNotFoundException"/>
  262. /// <exception cref="IOException"/>
  263. /// <exception cref="NotSupportedException"/>
  264. /// <exception cref="UnauthorizedAccessException"/>
  265. /// <param name="transaction">The transaction.</param>
  266. /// <param name="path">The directory to search.</param>
  267. /// <param name="searchPattern">
  268. /// The search string to match against the names of directories in <paramref name="path"/>.
  269. /// This parameter can contain a combination of valid literal path and wildcard
  270. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  271. /// </param>
  272. /// <param name="searchOption">
  273. /// One of the <see cref="SearchOption"/> enumeration values that specifies whether the <paramref name="searchOption"/>
  274. /// should include only the current directory or should include all subdirectories.
  275. /// </param>
  276. [SecurityCritical]
  277. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
  278. {
  279. var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
  280. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, options, PathFormat.RelativePath);
  281. }
  282. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  283. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  284. /// <exception cref="ArgumentException"/>
  285. /// <exception cref="ArgumentNullException"/>
  286. /// <exception cref="DirectoryNotFoundException"/>
  287. /// <exception cref="IOException"/>
  288. /// <exception cref="NotSupportedException"/>
  289. /// <exception cref="UnauthorizedAccessException"/>
  290. /// <param name="transaction">The transaction.</param>
  291. /// <param name="path">The directory to search.</param>
  292. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  293. [SecurityCritical]
  294. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  295. {
  296. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
  297. }
  298. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  299. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  300. /// <exception cref="ArgumentException"/>
  301. /// <exception cref="ArgumentNullException"/>
  302. /// <exception cref="DirectoryNotFoundException"/>
  303. /// <exception cref="IOException"/>
  304. /// <exception cref="NotSupportedException"/>
  305. /// <exception cref="UnauthorizedAccessException"/>
  306. /// <param name="transaction">The transaction.</param>
  307. /// <param name="path">The directory to search.</param>
  308. /// <param name="searchPattern">
  309. /// The search string to match against the names of directories in <paramref name="path"/>.
  310. /// This parameter can contain a combination of valid literal path and wildcard
  311. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  312. /// </param>
  313. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  314. [SecurityCritical]
  315. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat)
  316. {
  317. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
  318. }
  319. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>, and optionally searches subdirectories.</summary>
  320. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/> and <paramref name="searchOption"/>.</returns>
  321. /// <exception cref="ArgumentException"/>
  322. /// <exception cref="ArgumentNullException"/>
  323. /// <exception cref="DirectoryNotFoundException"/>
  324. /// <exception cref="IOException"/>
  325. /// <exception cref="NotSupportedException"/>
  326. /// <exception cref="UnauthorizedAccessException"/>
  327. /// <param name="transaction">The transaction.</param>
  328. /// <param name="path">The directory to search.</param>
  329. /// <param name="searchPattern">
  330. /// The search string to match against the names of directories in <paramref name="path"/>.
  331. /// This parameter can contain a combination of valid literal path and wildcard
  332. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  333. /// </param>
  334. /// <param name="searchOption">
  335. /// One of the <see cref="SearchOption"/> enumeration values that specifies whether the <paramref name="searchOption"/>
  336. /// should include only the current directory or should include all subdirectories.
  337. /// </param>
  338. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  339. [SecurityCritical]
  340. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
  341. {
  342. var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
  343. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, options, pathFormat);
  344. }
  345. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  346. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  347. /// <exception cref="ArgumentException"/>
  348. /// <exception cref="ArgumentNullException"/>
  349. /// <exception cref="DirectoryNotFoundException"/>
  350. /// <exception cref="IOException"/>
  351. /// <exception cref="NotSupportedException"/>
  352. /// <exception cref="UnauthorizedAccessException"/>
  353. /// <param name="transaction">The transaction.</param>
  354. /// <param name="path">The directory to search.</param>
  355. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  356. [SecurityCritical]
  357. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
  358. {
  359. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
  360. }
  361. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names in a specified <paramref name="path"/>.</summary>
  362. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/>.</returns>
  363. /// <exception cref="ArgumentException"/>
  364. /// <exception cref="ArgumentNullException"/>
  365. /// <exception cref="DirectoryNotFoundException"/>
  366. /// <exception cref="IOException"/>
  367. /// <exception cref="NotSupportedException"/>
  368. /// <exception cref="UnauthorizedAccessException"/>
  369. /// <param name="transaction">The transaction.</param>
  370. /// <param name="path">The directory to search.</param>
  371. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  372. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  373. [SecurityCritical]
  374. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
  375. {
  376. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, Path.WildcardStarMatchAll, options, pathFormat);
  377. }
  378. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  379. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  380. /// <exception cref="ArgumentException"/>
  381. /// <exception cref="ArgumentNullException"/>
  382. /// <exception cref="DirectoryNotFoundException"/>
  383. /// <exception cref="IOException"/>
  384. /// <exception cref="NotSupportedException"/>
  385. /// <exception cref="UnauthorizedAccessException"/>
  386. /// <param name="transaction">The transaction.</param>
  387. /// <param name="path">The directory to search.</param>
  388. /// <param name="searchPattern">
  389. /// The search string to match against the names of directories in <paramref name="path"/>.
  390. /// This parameter can contain a combination of valid literal path and wildcard
  391. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  392. /// </param>
  393. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  394. [SecurityCritical]
  395. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
  396. {
  397. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, options, PathFormat.RelativePath);
  398. }
  399. /// <summary>[AlphaFS] Returns an enumerable collection of file names and directory names that match a <paramref name="searchPattern"/> in a specified <paramref name="path"/>.</summary>
  400. /// <returns>An enumerable collection of file system entries in the directory specified by <paramref name="path"/> and that match the specified <paramref name="searchPattern"/>.</returns>
  401. /// <exception cref="ArgumentException"/>
  402. /// <exception cref="ArgumentNullException"/>
  403. /// <exception cref="DirectoryNotFoundException"/>
  404. /// <exception cref="IOException"/>
  405. /// <exception cref="NotSupportedException"/>
  406. /// <exception cref="UnauthorizedAccessException"/>
  407. /// <param name="transaction">The transaction.</param>
  408. /// <param name="path">The directory to search.</param>
  409. /// <param name="searchPattern">
  410. /// The search string to match against the names of directories in <paramref name="path"/>.
  411. /// This parameter can contain a combination of valid literal path and wildcard
  412. /// (<see cref="Path.WildcardStarMatchAll"/> and <see cref="Path.WildcardQuestion"/>) characters, but does not support regular expressions.
  413. /// </param>
  414. /// <param name="options"><see cref="DirectoryEnumerationOptions"/> flags that specify how the directory is to be enumerated.</param>
  415. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  416. [SecurityCritical]
  417. public static IEnumerable<string> EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
  418. {
  419. return EnumerateFileSystemEntryInfosCore<string>(transaction, path, searchPattern, options, pathFormat);
  420. }
  421. #endregion // Transactional
  422. }
  423. }