IFileSystem.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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="M:IFileSystem.GetFileSystemInfo(System.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="M:IFileSystem.GetFileSystemInfo(System.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. /// Normalizes the path.
  103. /// </summary>
  104. /// <param name="path">The path.</param>
  105. /// <returns>System.String.</returns>
  106. string NormalizePath(string path);
  107. /// <summary>
  108. /// Gets the file name without extension.
  109. /// </summary>
  110. /// <param name="info">The information.</param>
  111. /// <returns>System.String.</returns>
  112. string GetFileNameWithoutExtension(FileSystemMetadata info);
  113. /// <summary>
  114. /// Determines whether [is path file] [the specified path].
  115. /// </summary>
  116. /// <param name="path">The path.</param>
  117. /// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>
  118. bool IsPathFile(string path);
  119. /// <summary>
  120. /// Deletes the file.
  121. /// </summary>
  122. /// <param name="path">The path.</param>
  123. void DeleteFile(string path);
  124. /// <summary>
  125. /// Gets the directories.
  126. /// </summary>
  127. /// <param name="path">The path.</param>
  128. /// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
  129. /// <returns>All found directories.</returns>
  130. IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false);
  131. /// <summary>
  132. /// Gets the files.
  133. /// </summary>
  134. /// <param name="path">The path in which to search.</param>
  135. /// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
  136. /// <returns>All found files.</returns>
  137. IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
  138. IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  139. /// <summary>
  140. /// Gets the file system entries.
  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;FileSystemMetadata&gt;.</returns>
  145. IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
  146. /// <summary>
  147. /// Gets the directory 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> GetDirectoryPaths(string path, bool recursive = false);
  153. /// <summary>
  154. /// Gets the file paths.
  155. /// </summary>
  156. /// <param name="path">The path.</param>
  157. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  158. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  159. IEnumerable<string> GetFilePaths(string path, bool recursive = false);
  160. IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
  161. /// <summary>
  162. /// Gets the file system entry paths.
  163. /// </summary>
  164. /// <param name="path">The path.</param>
  165. /// <param name="recursive">if set to <c>true</c> [recursive].</param>
  166. /// <returns>IEnumerable&lt;System.String&gt;.</returns>
  167. IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
  168. void SetHidden(string path, bool isHidden);
  169. void SetAttributes(string path, bool isHidden, bool readOnly);
  170. List<FileSystemMetadata> GetDrives();
  171. }
  172. }