IFileSystem.cs 8.9 KB

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