repo creation with initial code after cloning public repo

This commit is contained in:
2026-02-19 07:36:25 -05:00
commit 460884fea3
2860 changed files with 650825 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
using System.IO;
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Helper class to create async <see cref="FileStream" />s.
/// </summary>
public static class AsyncFile
{
/// <summary>
/// Gets the default <see cref="FileStreamOptions"/> for reading files async.
/// </summary>
public static FileStreamOptions ReadOptions => new FileStreamOptions()
{
Options = FileOptions.Asynchronous
};
/// <summary>
/// Gets the default <see cref="FileStreamOptions"/> for writing files async.
/// </summary>
public static FileStreamOptions WriteOptions => new FileStreamOptions()
{
Mode = FileMode.OpenOrCreate,
Access = FileAccess.Write,
Share = FileShare.None,
Options = FileOptions.Asynchronous
};
/// <summary>
/// Creates, or truncates and overwrites, a file in the specified path.
/// </summary>
/// <param name="path">The path and name of the file to create.</param>
/// <returns>A <see cref="FileStream" /> that provides read/write access to the file specified in path.</returns>
public static FileStream Create(string path)
=> new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
/// <summary>
/// Opens an existing file for reading.
/// </summary>
/// <param name="path">The file to be opened for reading.</param>
/// <returns>A read-only <see cref="FileStream" /> on the specified path.</returns>
public static FileStream OpenRead(string path)
=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
/// <summary>
/// Opens an existing file for writing.
/// </summary>
/// <param name="path">The file to be opened for writing.</param>
/// <returns>An unshared <see cref="FileStream" /> object on the specified path with Write access.</returns>
public static FileStream OpenWrite(string path)
=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
}
}
@@ -0,0 +1,39 @@
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Class FileSystemEntryInfo.
/// </summary>
public class FileSystemEntryInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemEntryInfo" /> class.
/// </summary>
/// <param name="name">The filename.</param>
/// <param name="path">The file path.</param>
/// <param name="type">The file type.</param>
public FileSystemEntryInfo(string name, string path, FileSystemEntryType type)
{
Name = name;
Path = path;
Type = type;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; }
/// <summary>
/// Gets the path.
/// </summary>
/// <value>The path.</value>
public string Path { get; }
/// <summary>
/// Gets the type.
/// </summary>
/// <value>The type.</value>
public FileSystemEntryType Type { get; }
}
}
@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Enum FileSystemEntryType.
/// </summary>
public enum FileSystemEntryType
{
/// <summary>
/// The file.
/// </summary>
File,
/// <summary>
/// The directory.
/// </summary>
Directory,
/// <summary>
/// The network computer.
/// </summary>
NetworkComputer,
/// <summary>
/// The network share.
/// </summary>
NetworkShare
}
}
@@ -0,0 +1,58 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.IO
{
public class FileSystemMetadata
{
/// <summary>
/// Gets or sets a value indicating whether this <see cref="FileSystemMetadata"/> is exists.
/// </summary>
/// <value><c>true</c> if exists; otherwise, <c>false</c>.</value>
public bool Exists { get; set; }
/// <summary>
/// Gets or sets the full name.
/// </summary>
/// <value>The full name.</value>
public string FullName { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the extension.
/// </summary>
/// <value>The extension.</value>
public string Extension { get; set; }
/// <summary>
/// Gets or sets the length.
/// </summary>
/// <value>The length.</value>
public long Length { get; set; }
/// <summary>
/// Gets or sets the last write time UTC.
/// </summary>
/// <value>The last write time UTC.</value>
public DateTime LastWriteTimeUtc { get; set; }
/// <summary>
/// Gets or sets the creation time UTC.
/// </summary>
/// <value>The creation time UTC.</value>
public DateTime CreationTimeUtc { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is directory.
/// </summary>
/// <value><c>true</c> if this instance is directory; otherwise, <c>false</c>.</value>
public bool IsDirectory { get; set; }
}
}
+244
View File
@@ -0,0 +1,244 @@
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.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);
string MakeAbsolutePath(string folderPath, string filePath);
/// <summary>
/// Moves a directory to a new location.
/// </summary>
/// <param name="source">Source directory.</param>
/// <param name="destination">Destination directory.</param>
void MoveDirectory(string source, string destination);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified file or directory path.
/// </summary>
/// <param name="path">A path to a file or directory.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and all other properties will reflect the properties of the directory.</remarks>
FileSystemMetadata GetFileSystemInfo(string path);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified file path.
/// </summary>
/// <param name="path">A path to a file.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks><para>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property and the <see cref="FileSystemMetadata.Exists" /> property will both be set to false.</para>
/// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
FileSystemMetadata GetFileInfo(string path);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified directory path.
/// </summary>
/// <param name="path">A path to a directory.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks><para>If the specified path points to a file, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and the <see cref="FileSystemMetadata.Exists" /> property will be set to false.</para>
/// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
FileSystemMetadata GetDirectoryInfo(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 information.</param>
/// <returns>DateTime.</returns>
DateTime GetCreationTimeUtc(FileSystemMetadata info);
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>DateTime.</returns>
DateTime GetCreationTimeUtc(string path);
/// <summary>
/// Gets the last write time UTC.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>DateTime.</returns>
DateTime GetLastWriteTimeUtc(FileSystemMetadata info);
/// <summary>
/// Gets the last write time UTC.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>DateTime.</returns>
DateTime GetLastWriteTimeUtc(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);
bool AreEqual(string path1, string path2);
/// <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>
/// Gets the file name without extension.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>System.String.</returns>
string GetFileNameWithoutExtension(FileSystemMetadata info);
/// <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>
/// Gets the directories.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
/// <returns>All found directories.</returns>
IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false);
/// <summary>
/// Gets the files.
/// </summary>
/// <param name="path">The path in which to search.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
/// <returns>All found files.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
/// <summary>
/// Gets the files.
/// </summary>
/// <param name="path">The path in which to search.</param>
/// <param name="searchPattern">The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
/// <returns>All found files.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, string searchPattern, bool recursive = false);
/// <summary>
/// Gets the files.
/// </summary>
/// <param name="path">The path in which to search.</param>
/// <param name="extensions">The file extensions to search for.</param>
/// <param name="enableCaseSensitiveExtensions">Enable case-sensitive check for extensions.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
/// <returns>All found files.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary>
/// Gets the files.
/// </summary>
/// <param name="path">The path in which to search.</param>
/// <param name="searchPattern">The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.</param>
/// <param name="extensions">The file extensions to search for.</param>
/// <param name="enableCaseSensitiveExtensions">Enable case-sensitive check for extensions.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectories.</param>
/// <returns>All found files.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, string searchPattern, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary>
/// Gets the file system entries.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable&lt;FileSystemMetadata&gt;.</returns>
IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
/// <summary>
/// Gets the directory paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable&lt;System.String&gt;.</returns>
IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
/// <summary>
/// Gets the file paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable&lt;System.String&gt;.</returns>
IEnumerable<string> GetFilePaths(string path, bool recursive = false);
IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary>
/// Gets the file system entry paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable&lt;System.String&gt;.</returns>
IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
void SetHidden(string path, bool isHidden);
void SetAttributes(string path, bool isHidden, bool readOnly);
IEnumerable<FileSystemMetadata> GetDrives();
/// <summary>
/// Determines whether the directory exists.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>Whether the path exists.</returns>
bool DirectoryExists(string path);
/// <summary>
/// Determines whether the file exists.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>Whether the path exists.</returns>
bool FileExists(string path);
}
}
+25
View File
@@ -0,0 +1,25 @@
using System.IO;
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Class IODefaults.
/// </summary>
public static class IODefaults
{
/// <summary>
/// The default copy to buffer size.
/// </summary>
public const int CopyToBufferSize = 81920;
/// <summary>
/// The default file stream buffer size.
/// </summary>
public const int FileStreamBufferSize = 4096;
/// <summary>
/// The default <see cref="StreamWriter" /> buffer size.
/// </summary>
public const int StreamWriterBufferSize = 1024;
}
}
+27
View File
@@ -0,0 +1,27 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.IO
{
public interface IShortcutHandler
{
/// <summary>
/// Gets the extension.
/// </summary>
/// <value>The extension.</value>
string Extension { get; }
/// <summary>
/// Resolves the specified shortcut path.
/// </summary>
/// <param name="shortcutPath">The shortcut path.</param>
/// <returns>System.String.</returns>
string? Resolve(string shortcutPath);
/// <summary>
/// Creates the specified shortcut path.
/// </summary>
/// <param name="shortcutPath">The shortcut path.</param>
/// <param name="targetPath">The target path.</param>
void Create(string shortcutPath, string targetPath);
}
}
+18
View File
@@ -0,0 +1,18 @@
#pragma warning disable CS1591
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Model.IO
{
public interface IStreamHelper
{
Task CopyToAsync(Stream source, Stream destination, int bufferSize, Action? onStarted, CancellationToken cancellationToken);
Task CopyToAsync(Stream source, Stream destination, int bufferSize, int emptyReadLimit, CancellationToken cancellationToken);
Task CopyUntilCancelled(Stream source, Stream target, int bufferSize, CancellationToken cancellationToken);
}
}