IFileSystem.cs 8.8 KB

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