From ef6b90b8e6e6c317fcda85a392c79324f91250db Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 25 Oct 2016 15:02:04 -0400 Subject: make controller project portable --- MediaBrowser.Model/IO/IFileSystem.cs | 414 +++++++++++++++++++++++++++++++++++ 1 file changed, 414 insertions(+) create mode 100644 MediaBrowser.Model/IO/IFileSystem.cs (limited to 'MediaBrowser.Model/IO/IFileSystem.cs') diff --git a/MediaBrowser.Model/IO/IFileSystem.cs b/MediaBrowser.Model/IO/IFileSystem.cs new file mode 100644 index 000000000..4ff4fc604 --- /dev/null +++ b/MediaBrowser.Model/IO/IFileSystem.cs @@ -0,0 +1,414 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace MediaBrowser.Model.IO +{ + /// + /// Interface IFileSystem + /// + public interface IFileSystem + { + /// + /// Determines whether the specified filename is shortcut. + /// + /// The filename. + /// true if the specified filename is shortcut; otherwise, false. + bool IsShortcut(string filename); + + /// + /// Resolves the shortcut. + /// + /// The filename. + /// System.String. + string ResolveShortcut(string filename); + + /// + /// Creates the shortcut. + /// + /// The shortcut path. + /// The target. + void CreateShortcut(string shortcutPath, string target); + + /// + /// Returns a object for the specified file or directory path. + /// + /// A path to a file or directory. + /// A object. + /// If the specified path points to a directory, the returned object's + /// property will be set to true and all other properties will reflect the properties of the directory. + FileSystemMetadata GetFileSystemInfo(string path); + + /// + /// Returns a object for the specified file path. + /// + /// A path to a file. + /// A object. + /// If the specified path points to a directory, the returned object's + /// property and the property will both be set to false. + /// For automatic handling of files and directories, use . + FileSystemMetadata GetFileInfo(string path); + + /// + /// Returns a object for the specified directory path. + /// + /// A path to a directory. + /// A object. + /// If the specified path points to a file, the returned object's + /// property will be set to true and the property will be set to false. + /// For automatic handling of files and directories, use . + FileSystemMetadata GetDirectoryInfo(string path); + + /// + /// Gets the valid filename. + /// + /// The filename. + /// System.String. + string GetValidFilename(string filename); + + /// + /// Gets the creation time UTC. + /// + /// The information. + /// DateTime. + DateTime GetCreationTimeUtc(FileSystemMetadata info); + + /// + /// Gets the creation time UTC. + /// + /// The path. + /// DateTime. + DateTime GetCreationTimeUtc(string path); + + /// + /// Gets the last write time UTC. + /// + /// The information. + /// DateTime. + DateTime GetLastWriteTimeUtc(FileSystemMetadata info); + + /// + /// Gets the last write time UTC. + /// + /// The path. + /// DateTime. + DateTime GetLastWriteTimeUtc(string path); + + /// + /// Gets the file stream. + /// + /// The path. + /// The mode. + /// The access. + /// The share. + /// if set to true [is asynchronous]. + /// FileStream. + Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false); + + /// + /// Opens the read. + /// + /// The path. + /// Stream. + Stream OpenRead(String path); + + /// + /// Swaps the files. + /// + /// The file1. + /// The file2. + void SwapFiles(string file1, string file2); + + /// + /// Determines whether [contains sub path] [the specified parent path]. + /// + /// The parent path. + /// The path. + /// true if [contains sub path] [the specified parent path]; otherwise, false. + bool ContainsSubPath(string parentPath, string path); + + /// + /// Determines whether [is root path] [the specified path]. + /// + /// The path. + /// true if [is root path] [the specified path]; otherwise, false. + bool IsRootPath(string path); + + /// + /// Normalizes the path. + /// + /// The path. + /// System.String. + string NormalizePath(string path); + + /// + /// Gets the file name without extension. + /// + /// The information. + /// System.String. + string GetFileNameWithoutExtension(FileSystemMetadata info); + + /// + /// Gets the file name without extension. + /// + /// The path. + /// System.String. + string GetFileNameWithoutExtension(string path); + + /// + /// Determines whether [is path file] [the specified path]. + /// + /// The path. + /// true if [is path file] [the specified path]; otherwise, false. + bool IsPathFile(string path); + + /// + /// Deletes the file. + /// + /// The path. + void DeleteFile(string path); + + /// + /// Deletes the directory. + /// + /// The path. + /// if set to true [recursive]. + void DeleteDirectory(string path, bool recursive); + + /// + /// Gets the directories. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<DirectoryInfo>. + IEnumerable GetDirectories(string path, bool recursive = false); + + /// + /// Gets the files. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<FileInfo>. + IEnumerable GetFiles(string path, bool recursive = false); + + /// + /// Gets the file system entries. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<FileSystemMetadata>. + IEnumerable GetFileSystemEntries(string path, bool recursive = false); + + /// + /// Creates the directory. + /// + /// The path. + void CreateDirectory(string path); + + /// + /// Copies the file. + /// + /// The source. + /// The target. + /// if set to true [overwrite]. + void CopyFile(string source, string target, bool overwrite); + + /// + /// Moves the file. + /// + /// The source. + /// The target. + void MoveFile(string source, string target); + + /// + /// Moves the directory. + /// + /// The source. + /// The target. + void MoveDirectory(string source, string target); + + /// + /// Directories the exists. + /// + /// The path. + /// true if XXXX, false otherwise. + bool DirectoryExists(string path); + + /// + /// Files the exists. + /// + /// The path. + /// true if XXXX, false otherwise. + bool FileExists(string path); + + /// + /// Reads all text. + /// + /// The path. + /// System.String. + string ReadAllText(string path); + + /// + /// Writes all text. + /// + /// The path. + /// The text. + void WriteAllText(string path, string text); + + /// + /// Writes all text. + /// + /// The path. + /// The text. + /// The encoding. + void WriteAllText(string path, string text, Encoding encoding); + + /// + /// Reads all text. + /// + /// The path. + /// The encoding. + /// System.String. + string ReadAllText(string path, Encoding encoding); + + /// + /// Gets the directory paths. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<System.String>. + IEnumerable GetDirectoryPaths(string path, bool recursive = false); + + /// + /// Gets the file paths. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<System.String>. + IEnumerable GetFilePaths(string path, bool recursive = false); + + /// + /// Gets the file system entry paths. + /// + /// The path. + /// if set to true [recursive]. + /// IEnumerable<System.String>. + IEnumerable GetFileSystemEntryPaths(string path, bool recursive = false); + + void SetHidden(string path, bool isHidden); + } + + public enum FileOpenMode + { + // + // Summary: + // Specifies that the operating system should create a new file. This requires System.Security.Permissions.FileIOPermissionAccess.Write + // permission. If the file already exists, an System.IO.IOException exception is + // thrown. + CreateNew = 1, + // + // Summary: + // Specifies that the operating system should create a new file. If the file already + // exists, it will be overwritten. This requires System.Security.Permissions.FileIOPermissionAccess.Write + // permission. FileMode.Create is equivalent to requesting that if the file does + // not exist, use System.IO.FileMode.CreateNew; otherwise, use System.IO.FileMode.Truncate. + // If the file already exists but is a hidden file, an System.UnauthorizedAccessException + // exception is thrown. + Create = 2, + // + // Summary: + // Specifies that the operating system should open an existing file. The ability + // to open the file is dependent on the value specified by the System.IO.FileAccess + // enumeration. A System.IO.FileNotFoundException exception is thrown if the file + // does not exist. + Open = 3, + // + // Summary: + // Specifies that the operating system should open a file if it exists; otherwise, + // a new file should be created. If the file is opened with FileAccess.Read, System.Security.Permissions.FileIOPermissionAccess.Read + // permission is required. If the file access is FileAccess.Write, System.Security.Permissions.FileIOPermissionAccess.Write + // permission is required. If the file is opened with FileAccess.ReadWrite, both + // System.Security.Permissions.FileIOPermissionAccess.Read and System.Security.Permissions.FileIOPermissionAccess.Write + // permissions are required. + OpenOrCreate = 4, + // + // Summary: + // Specifies that the operating system should open an existing file. When the file + // is opened, it should be truncated so that its size is zero bytes. This requires + // System.Security.Permissions.FileIOPermissionAccess.Write permission. Attempts + // to read from a file opened with FileMode.Truncate cause an System.ArgumentException + // exception. + Truncate = 5, + // + // Summary: + // Opens the file if it exists and seeks to the end of the file, or creates a new + // file. This requires System.Security.Permissions.FileIOPermissionAccess.Append + // permission. FileMode.Append can be used only in conjunction with FileAccess.Write. + // Trying to seek to a position before the end of the file throws an System.IO.IOException + // exception, and any attempt to read fails and throws a System.NotSupportedException + // exception. + Append = 6 + } + + [Flags] + public enum FileAccessMode + { + // + // Summary: + // Read access to the file. Data can be read from the file. Combine with Write for + // read/write access. + Read = 1, + // + // Summary: + // Write access to the file. Data can be written to the file. Combine with Read + // for read/write access. + Write = 2, + // + // Summary: + // Read and write access to the file. Data can be written to and read from the file. + ReadWrite = 3 + } + + [Flags] + public enum FileShareMode + { + // + // Summary: + // Declines sharing of the current file. Any request to open the file (by this process + // or another process) will fail until the file is closed. + None = 0, + // + // Summary: + // Allows subsequent opening of the file for reading. If this flag is not specified, + // any request to open the file for reading (by this process or another process) + // will fail until the file is closed. However, even if this flag is specified, + // additional permissions might still be needed to access the file. + Read = 1, + // + // Summary: + // Allows subsequent opening of the file for writing. If this flag is not specified, + // any request to open the file for writing (by this process or another process) + // will fail until the file is closed. However, even if this flag is specified, + // additional permissions might still be needed to access the file. + Write = 2, + // + // Summary: + // Allows subsequent opening of the file for reading or writing. If this flag is + // not specified, any request to open the file for reading or writing (by this process + // or another process) will fail until the file is closed. However, even if this + // flag is specified, additional permissions might still be needed to access the + // file. + ReadWrite = 3, + // + // Summary: + // Allows subsequent deleting of a file. + Delete = 4, + // + // Summary: + // Makes the file handle inheritable by child processes. This is not directly supported + // by Win32. + Inheritable = 16 + } + +} -- cgit v1.2.3