2
0

IFileSystem.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MediaBrowser.Model.IO
  5. {
  6. /// <summary>
  7. /// Interface IFileSystem.
  8. /// </summary>
  9. public interface IFileSystem
  10. {
  11. /// <summary>
  12. /// Determines whether the specified filename is shortcut.
  13. /// </summary>
  14. /// <param name="filename">The filename.</param>
  15. /// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
  16. bool IsShortcut(string filename);
  17. /// <summary>
  18. /// Resolves the shortcut.
  19. /// </summary>
  20. /// <param name="filename">The filename.</param>
  21. /// <returns>System.String.</returns>
  22. string? ResolveShortcut(string filename);
  23. /// <summary>
  24. /// Creates the shortcut.
  25. /// </summary>
  26. /// <param name="shortcutPath">The shortcut path.</param>
  27. /// <param name="target">The target.</param>
  28. void CreateShortcut(string shortcutPath, string target);
  29. string MakeAbsolutePath(string folderPath, string filePath);
  30. /// <summary>
  31. /// Returns a <see cref="FileSystemMetadata" /> object for the specified file or directory path.
  32. /// </summary>
  33. /// <param name="path">A path to a file or directory.</param>
  34. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  35. /// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
  36. /// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and all other properties will reflect the properties of the directory.</remarks>
  37. FileSystemMetadata GetFileSystemInfo(string path);
  38. /// <summary>
  39. /// Returns a <see cref="FileSystemMetadata" /> object for the specified file path.
  40. /// </summary>
  41. /// <param name="path">A path to a file.</param>
  42. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  43. /// <remarks><para>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
  44. /// <see cref="FileSystemMetadata.IsDirectory" /> property and the <see cref="FileSystemMetadata.Exists" /> property will both be set to false.</para>
  45. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
  46. FileSystemMetadata GetFileInfo(string path);
  47. /// <summary>
  48. /// Returns a <see cref="FileSystemMetadata" /> object for the specified directory path.
  49. /// </summary>
  50. /// <param name="path">A path to a directory.</param>
  51. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  52. /// <remarks><para>If the specified path points to a file, the returned <see cref="FileSystemMetadata" /> object's
  53. /// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and the <see cref="FileSystemMetadata.Exists" /> property will be set to false.</para>
  54. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
  55. FileSystemMetadata GetDirectoryInfo(string path);
  56. /// <summary>
  57. /// Gets the valid filename.
  58. /// </summary>
  59. /// <param name="filename">The filename.</param>
  60. /// <returns>System.String.</returns>
  61. string GetValidFilename(string filename);
  62. /// <summary>
  63. /// Gets the creation time UTC.
  64. /// </summary>
  65. /// <param name="info">The information.</param>
  66. /// <returns>DateTime.</returns>
  67. DateTime GetCreationTimeUtc(FileSystemMetadata info);
  68. /// <summary>
  69. /// Gets the creation time UTC.
  70. /// </summary>
  71. /// <param name="path">The path.</param>
  72. /// <returns>DateTime.</returns>
  73. DateTime GetCreationTimeUtc(string path);
  74. /// <summary>
  75. /// Gets the last write time UTC.
  76. /// </summary>
  77. /// <param name="info">The information.</param>
  78. /// <returns>DateTime.</returns>
  79. DateTime GetLastWriteTimeUtc(FileSystemMetadata info);
  80. /// <summary>
  81. /// Gets the last write time UTC.
  82. /// </summary>
  83. /// <param name="path">The path.</param>
  84. /// <returns>DateTime.</returns>
  85. DateTime GetLastWriteTimeUtc(string path);
  86. /// <summary>
  87. /// Swaps the files.
  88. /// </summary>
  89. /// <param name="file1">The file1.</param>
  90. /// <param name="file2">The file2.</param>
  91. void SwapFiles(string file1, string file2);
  92. bool AreEqual(string path1, string path2);
  93. /// <summary>
  94. /// Determines whether [contains sub path] [the specified parent path].
  95. /// </summary>
  96. /// <param name="parentPath">The parent path.</param>
  97. /// <param name="path">The path.</param>
  98. /// <returns><c>true</c> if [contains sub path] [the specified parent path]; otherwise, <c>false</c>.</returns>
  99. bool ContainsSubPath(string parentPath, string path);
  100. /// <summary>
  101. /// Gets the file name without extension.
  102. /// </summary>
  103. /// <param name="info">The information.</param>
  104. /// <returns>System.String.</returns>
  105. string GetFileNameWithoutExtension(FileSystemMetadata info);
  106. /// <summary>
  107. /// Determines whether [is path file] [the specified path].
  108. /// </summary>
  109. /// <param name="path">The path.</param>
  110. /// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>
  111. bool IsPathFile(string path);
  112. /// <summary>
  113. /// Deletes the file.
  114. /// </summary>
  115. /// <param name="path">The path.</param>
  116. void DeleteFile(string path);
  117. /// <summary>
  118. /// Gets the directories.
  119. /// </summary>
  120. /// <param name="path">The path.</param>
  121. /// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
  122. /// <returns>All found directories.</returns>
  123. IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false);
  124. /// <summary>
  125. /// Gets the files.
  126. /// </summary>
  127. /// <param name="path">The path in which to search.</param>
  128. /// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
  129. /// <returns>All found files.</returns>
  130. IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
  131. IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  132. /// <summary>
  133. /// Gets the file system entries.
  134. /// </summary>
  135. /// <param name="path">The path.</param>
  136. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  137. /// <returns>IEnumerable&lt;FileSystemMetadata&gt;.</returns>
  138. IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
  139. /// <summary>
  140. /// Gets the directory paths.
  141. /// </summary>
  142. /// <param name="path">The path.</param>
  143. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  144. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  145. IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
  146. /// <summary>
  147. /// Gets the file paths.
  148. /// </summary>
  149. /// <param name="path">The path.</param>
  150. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  151. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  152. IEnumerable<string> GetFilePaths(string path, bool recursive = false);
  153. IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  154. /// <summary>
  155. /// Gets the file system entry paths.
  156. /// </summary>
  157. /// <param name="path">The path.</param>
  158. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  159. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  160. IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
  161. void SetHidden(string path, bool isHidden);
  162. void SetAttributes(string path, bool isHidden, bool readOnly);
  163. IEnumerable<FileSystemMetadata> GetDrives();
  164. /// <summary>
  165. /// Determines whether the directory exists.
  166. /// </summary>
  167. /// <param name="path">The path.</param>
  168. /// <returns>Whether the path exists.</returns>
  169. bool DirectoryExists(string path);
  170. /// <summary>
  171. /// Determines whether the file exists.
  172. /// </summary>
  173. /// <param name="path">The path.</param>
  174. /// <returns>Whether the path exists.</returns>
  175. bool FileExists(string path);
  176. }
  177. }