IFileSystem.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. /// Moves a directory to a new location.
  32. /// </summary>
  33. /// <param name="source">Source directory.</param>
  34. /// <param name="destination">Destination directory.</param>
  35. void MoveDirectory(string source, string destination);
  36. /// <summary>
  37. /// Returns a <see cref="FileSystemMetadata" /> object for the specified file or directory path.
  38. /// </summary>
  39. /// <param name="path">A path to a file or directory.</param>
  40. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  41. /// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
  42. /// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and all other properties will reflect the properties of the directory.</remarks>
  43. FileSystemMetadata GetFileSystemInfo(string path);
  44. /// <summary>
  45. /// Returns a <see cref="FileSystemMetadata" /> object for the specified file path.
  46. /// </summary>
  47. /// <param name="path">A path to a file.</param>
  48. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  49. /// <remarks><para>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
  50. /// <see cref="FileSystemMetadata.IsDirectory" /> property and the <see cref="FileSystemMetadata.Exists" /> property will both be set to false.</para>
  51. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
  52. FileSystemMetadata GetFileInfo(string path);
  53. /// <summary>
  54. /// Returns a <see cref="FileSystemMetadata" /> object for the specified directory path.
  55. /// </summary>
  56. /// <param name="path">A path to a directory.</param>
  57. /// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
  58. /// <remarks><para>If the specified path points to a file, the returned <see cref="FileSystemMetadata" /> object's
  59. /// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and the <see cref="FileSystemMetadata.Exists" /> property will be set to false.</para>
  60. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
  61. FileSystemMetadata GetDirectoryInfo(string path);
  62. /// <summary>
  63. /// Gets the valid filename.
  64. /// </summary>
  65. /// <param name="filename">The filename.</param>
  66. /// <returns>System.String.</returns>
  67. string GetValidFilename(string filename);
  68. /// <summary>
  69. /// Gets the creation time UTC.
  70. /// </summary>
  71. /// <param name="info">The information.</param>
  72. /// <returns>DateTime.</returns>
  73. DateTime GetCreationTimeUtc(FileSystemMetadata info);
  74. /// <summary>
  75. /// Gets the creation time UTC.
  76. /// </summary>
  77. /// <param name="path">The path.</param>
  78. /// <returns>DateTime.</returns>
  79. DateTime GetCreationTimeUtc(string path);
  80. /// <summary>
  81. /// Gets the last write time UTC.
  82. /// </summary>
  83. /// <param name="info">The information.</param>
  84. /// <returns>DateTime.</returns>
  85. DateTime GetLastWriteTimeUtc(FileSystemMetadata info);
  86. /// <summary>
  87. /// Gets the last write time UTC.
  88. /// </summary>
  89. /// <param name="path">The path.</param>
  90. /// <returns>DateTime.</returns>
  91. DateTime GetLastWriteTimeUtc(string path);
  92. /// <summary>
  93. /// Swaps the files.
  94. /// </summary>
  95. /// <param name="file1">The file1.</param>
  96. /// <param name="file2">The file2.</param>
  97. void SwapFiles(string file1, string file2);
  98. bool AreEqual(string path1, string path2);
  99. /// <summary>
  100. /// Determines whether [contains sub path] [the specified parent path].
  101. /// </summary>
  102. /// <param name="parentPath">The parent path.</param>
  103. /// <param name="path">The path.</param>
  104. /// <returns><c>true</c> if [contains sub path] [the specified parent path]; otherwise, <c>false</c>.</returns>
  105. bool ContainsSubPath(string parentPath, string path);
  106. /// <summary>
  107. /// Gets the file name without extension.
  108. /// </summary>
  109. /// <param name="info">The information.</param>
  110. /// <returns>System.String.</returns>
  111. string GetFileNameWithoutExtension(FileSystemMetadata info);
  112. /// <summary>
  113. /// Determines whether [is path file] [the specified path].
  114. /// </summary>
  115. /// <param name="path">The path.</param>
  116. /// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>
  117. bool IsPathFile(string path);
  118. /// <summary>
  119. /// Deletes the file.
  120. /// </summary>
  121. /// <param name="path">The path.</param>
  122. void DeleteFile(string path);
  123. /// <summary>
  124. /// Gets the directories.
  125. /// </summary>
  126. /// <param name="path">The path.</param>
  127. /// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
  128. /// <returns>All found directories.</returns>
  129. IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false);
  130. /// <summary>
  131. /// Gets the files.
  132. /// </summary>
  133. /// <param name="path">The path in which to search.</param>
  134. /// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
  135. /// <returns>All found files.</returns>
  136. IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
  137. /// <summary>
  138. /// Gets the files.
  139. /// </summary>
  140. /// <param name="path">The path in which to search.</param>
  141. /// <param name="searchPattern">The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.</param>
  142. /// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
  143. /// <returns>All found files.</returns>
  144. IEnumerable<FileSystemMetadata> GetFiles(string path, string searchPattern, bool recursive = false);
  145. /// <summary>
  146. /// Gets the files.
  147. /// </summary>
  148. /// <param name="path">The path in which to search.</param>
  149. /// <param name="extensions">The file extensions to search for.</param>
  150. /// <param name="enableCaseSensitiveExtensions">Enable case-sensitive check for extensions.</param>
  151. /// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
  152. /// <returns>All found files.</returns>
  153. IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  154. /// <summary>
  155. /// Gets the files.
  156. /// </summary>
  157. /// <param name="path">The path in which to search.</param>
  158. /// <param name="searchPattern">The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.</param>
  159. /// <param name="extensions">The file extensions to search for.</param>
  160. /// <param name="enableCaseSensitiveExtensions">Enable case-sensitive check for extensions.</param>
  161. /// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
  162. /// <returns>All found files.</returns>
  163. IEnumerable<FileSystemMetadata> GetFiles(string path, string searchPattern, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  164. /// <summary>
  165. /// Gets the file system entries.
  166. /// </summary>
  167. /// <param name="path">The path.</param>
  168. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  169. /// <returns>IEnumerable&lt;FileSystemMetadata&gt;.</returns>
  170. IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
  171. /// <summary>
  172. /// Gets the directory paths.
  173. /// </summary>
  174. /// <param name="path">The path.</param>
  175. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  176. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  177. IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
  178. /// <summary>
  179. /// Gets the file paths.
  180. /// </summary>
  181. /// <param name="path">The path.</param>
  182. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  183. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  184. IEnumerable<string> GetFilePaths(string path, bool recursive = false);
  185. IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  186. /// <summary>
  187. /// Gets the file system entry paths.
  188. /// </summary>
  189. /// <param name="path">The path.</param>
  190. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  191. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  192. IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
  193. void SetHidden(string path, bool isHidden);
  194. void SetAttributes(string path, bool isHidden, bool readOnly);
  195. IEnumerable<FileSystemMetadata> GetDrives();
  196. /// <summary>
  197. /// Determines whether the directory exists.
  198. /// </summary>
  199. /// <param name="path">The path.</param>
  200. /// <returns>Whether the path exists.</returns>
  201. bool DirectoryExists(string path);
  202. /// <summary>
  203. /// Determines whether the file exists.
  204. /// </summary>
  205. /// <param name="path">The path.</param>
  206. /// <returns>Whether the path exists.</returns>
  207. bool FileExists(string path);
  208. }
  209. }