IFileSystem.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  138. /// <summary>
  139. /// Gets the file system entries.
  140. /// </summary>
  141. /// <param name="path">The path.</param>
  142. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  143. /// <returns>IEnumerable&lt;FileSystemMetadata&gt;.</returns>
  144. IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
  145. /// <summary>
  146. /// Gets the directory paths.
  147. /// </summary>
  148. /// <param name="path">The path.</param>
  149. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  150. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  151. IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
  152. /// <summary>
  153. /// Gets the file paths.
  154. /// </summary>
  155. /// <param name="path">The path.</param>
  156. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  157. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  158. IEnumerable<string> GetFilePaths(string path, bool recursive = false);
  159. IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  160. /// <summary>
  161. /// Gets the file system entry paths.
  162. /// </summary>
  163. /// <param name="path">The path.</param>
  164. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  165. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  166. IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
  167. void SetHidden(string path, bool isHidden);
  168. void SetAttributes(string path, bool isHidden, bool readOnly);
  169. IEnumerable<FileSystemMetadata> GetDrives();
  170. /// <summary>
  171. /// Determines whether the directory exists.
  172. /// </summary>
  173. /// <param name="path">The path.</param>
  174. /// <returns>Whether the path exists.</returns>
  175. bool DirectoryExists(string path);
  176. /// <summary>
  177. /// Determines whether the file exists.
  178. /// </summary>
  179. /// <param name="path">The path.</param>
  180. /// <returns>Whether the path exists.</returns>
  181. bool FileExists(string path);
  182. }
  183. }