IFileSystem.cs 8.8 KB

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