IFileSystem.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System;
  2. using System.IO;
  3. namespace MediaBrowser.Common.IO
  4. {
  5. /// <summary>
  6. /// Interface IFileSystem
  7. /// </summary>
  8. public interface IFileSystem
  9. {
  10. /// <summary>
  11. /// Determines whether the specified filename is shortcut.
  12. /// </summary>
  13. /// <param name="filename">The filename.</param>
  14. /// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
  15. bool IsShortcut(string filename);
  16. /// <summary>
  17. /// Resolves the shortcut.
  18. /// </summary>
  19. /// <param name="filename">The filename.</param>
  20. /// <returns>System.String.</returns>
  21. string ResolveShortcut(string filename);
  22. /// <summary>
  23. /// Creates the shortcut.
  24. /// </summary>
  25. /// <param name="shortcutPath">The shortcut path.</param>
  26. /// <param name="target">The target.</param>
  27. void CreateShortcut(string shortcutPath, string target);
  28. /// <summary>
  29. /// Gets the file system info.
  30. /// </summary>
  31. /// <param name="path">The path.</param>
  32. /// <returns>FileSystemInfo.</returns>
  33. FileSystemInfo GetFileSystemInfo(string path);
  34. /// <summary>
  35. /// Gets the valid filename.
  36. /// </summary>
  37. /// <param name="filename">The filename.</param>
  38. /// <returns>System.String.</returns>
  39. string GetValidFilename(string filename);
  40. /// <summary>
  41. /// Gets the creation time UTC.
  42. /// </summary>
  43. /// <param name="info">The info.</param>
  44. /// <returns>DateTime.</returns>
  45. DateTime GetCreationTimeUtc(FileSystemInfo info);
  46. /// <summary>
  47. /// Gets the last write time UTC.
  48. /// </summary>
  49. /// <param name="info">The information.</param>
  50. /// <returns>DateTime.</returns>
  51. DateTime GetLastWriteTimeUtc(FileSystemInfo info);
  52. /// <summary>
  53. /// Gets the last write time UTC.
  54. /// </summary>
  55. /// <param name="path">The path.</param>
  56. /// <returns>DateTime.</returns>
  57. DateTime GetLastWriteTimeUtc(string path);
  58. /// <summary>
  59. /// Gets the file stream.
  60. /// </summary>
  61. /// <param name="path">The path.</param>
  62. /// <param name="mode">The mode.</param>
  63. /// <param name="access">The access.</param>
  64. /// <param name="share">The share.</param>
  65. /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
  66. /// <returns>FileStream.</returns>
  67. FileStream GetFileStream(string path, FileMode mode, FileAccess access, FileShare share, bool isAsync = false);
  68. /// <summary>
  69. /// Swaps the files.
  70. /// </summary>
  71. /// <param name="file1">The file1.</param>
  72. /// <param name="file2">The file2.</param>
  73. void SwapFiles(string file1, string file2);
  74. /// <summary>
  75. /// Determines whether [contains sub path] [the specified parent path].
  76. /// </summary>
  77. /// <param name="parentPath">The parent path.</param>
  78. /// <param name="path">The path.</param>
  79. /// <returns><c>true</c> if [contains sub path] [the specified parent path]; otherwise, <c>false</c>.</returns>
  80. bool ContainsSubPath(string parentPath, string path);
  81. /// <summary>
  82. /// Determines whether [is root path] [the specified path].
  83. /// </summary>
  84. /// <param name="path">The path.</param>
  85. /// <returns><c>true</c> if [is root path] [the specified path]; otherwise, <c>false</c>.</returns>
  86. bool IsRootPath(string path);
  87. /// <summary>
  88. /// Normalizes the path.
  89. /// </summary>
  90. /// <param name="path">The path.</param>
  91. /// <returns>System.String.</returns>
  92. string NormalizePath(string path);
  93. /// <summary>
  94. /// Substitutes the path.
  95. /// </summary>
  96. /// <param name="path">The path.</param>
  97. /// <param name="from">From.</param>
  98. /// <param name="to">To.</param>
  99. /// <returns>System.String.</returns>
  100. string SubstitutePath(string path, string from, string to);
  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(FileSystemInfo info);
  107. /// <summary>
  108. /// Gets the file name without extension.
  109. /// </summary>
  110. /// <param name="path">The path.</param>
  111. /// <returns>System.String.</returns>
  112. string GetFileNameWithoutExtension(string path);
  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. }
  120. }