123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Text;
- namespace MediaBrowser.Common.IO
- {
- /// <summary>
- /// Interface IFileSystem
- /// </summary>
- public interface IFileSystem
- {
- /// <summary>
- /// Determines whether the specified filename is shortcut.
- /// </summary>
- /// <param name="filename">The filename.</param>
- /// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
- bool IsShortcut(string filename);
- /// <summary>
- /// Resolves the shortcut.
- /// </summary>
- /// <param name="filename">The filename.</param>
- /// <returns>System.String.</returns>
- string ResolveShortcut(string filename);
- /// <summary>
- /// Creates the shortcut.
- /// </summary>
- /// <param name="shortcutPath">The shortcut path.</param>
- /// <param name="target">The target.</param>
- void CreateShortcut(string shortcutPath, string target);
- /// <summary>
- /// Gets the file system info.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns>FileSystemInfo.</returns>
- FileSystemInfo GetFileSystemInfo(string path);
- /// <summary>
- /// Gets the valid filename.
- /// </summary>
- /// <param name="filename">The filename.</param>
- /// <returns>System.String.</returns>
- string GetValidFilename(string filename);
- /// <summary>
- /// Gets the creation time UTC.
- /// </summary>
- /// <param name="info">The info.</param>
- /// <returns>DateTime.</returns>
- DateTime GetCreationTimeUtc(FileSystemInfo info);
- /// <summary>
- /// Gets the last write time UTC.
- /// </summary>
- /// <param name="info">The information.</param>
- /// <returns>DateTime.</returns>
- DateTime GetLastWriteTimeUtc(FileSystemInfo info);
- /// <summary>
- /// Gets the last write time UTC.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns>DateTime.</returns>
- DateTime GetLastWriteTimeUtc(string path);
- /// <summary>
- /// Gets the file stream.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="mode">The mode.</param>
- /// <param name="access">The access.</param>
- /// <param name="share">The share.</param>
- /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
- /// <returns>FileStream.</returns>
- Stream GetFileStream(string path, FileMode mode, FileAccess access, FileShare share, bool isAsync = false);
- Stream OpenRead(String path);
- /// <summary>
- /// Swaps the files.
- /// </summary>
- /// <param name="file1">The file1.</param>
- /// <param name="file2">The file2.</param>
- void SwapFiles(string file1, string file2);
- /// <summary>
- /// Determines whether [contains sub path] [the specified parent path].
- /// </summary>
- /// <param name="parentPath">The parent path.</param>
- /// <param name="path">The path.</param>
- /// <returns><c>true</c> if [contains sub path] [the specified parent path]; otherwise, <c>false</c>.</returns>
- bool ContainsSubPath(string parentPath, string path);
- /// <summary>
- /// Determines whether [is root path] [the specified path].
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns><c>true</c> if [is root path] [the specified path]; otherwise, <c>false</c>.</returns>
- bool IsRootPath(string path);
- /// <summary>
- /// Normalizes the path.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns>System.String.</returns>
- string NormalizePath(string path);
- /// <summary>
- /// Substitutes the path.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="from">From.</param>
- /// <param name="to">To.</param>
- /// <returns>System.String.</returns>
- string SubstitutePath(string path, string from, string to);
- /// <summary>
- /// Gets the file name without extension.
- /// </summary>
- /// <param name="info">The information.</param>
- /// <returns>System.String.</returns>
- string GetFileNameWithoutExtension(FileSystemInfo info);
- /// <summary>
- /// Gets the file name without extension.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns>System.String.</returns>
- string GetFileNameWithoutExtension(string path);
- /// <summary>
- /// Determines whether [is path file] [the specified path].
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>
- bool IsPathFile(string path);
- /// <summary>
- /// Deletes the file.
- /// </summary>
- /// <param name="path">The path.</param>
- void DeleteFile(string path);
- /// <summary>
- /// Deletes the directory.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="recursive">if set to <c>true</c> [recursive].</param>
- void DeleteDirectory(string path, bool recursive);
-
- IEnumerable<DirectoryInfo> GetDirectories(string path, bool recursive = false);
- IEnumerable<FileInfo> GetFiles(string path, bool recursive = false);
- IEnumerable<FileSystemInfo> GetFileSystemEntries(string path, bool recursive = false);
- void CreateDirectory(string path);
- void CopyFile(string source, string target, bool overwrite);
- void MoveFile(string source, string target);
- void MoveDirectory(string source, string target);
- bool DirectoryExists(string path);
- bool FileExists(string path);
- string ReadAllText(string path);
- void WriteAllText(string path, string text);
-
- void WriteAllText(string path, string text, Encoding encoding);
- string ReadAllText(string path, Encoding encoding);
- IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
- IEnumerable<string> GetFilePaths(string path, bool recursive = false);
- IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
- }
- }
|