using System; using System.IO; namespace MediaBrowser.Model.IO { /// /// Helper class to create async s. /// public static class AsyncFile { /// /// Gets a value indicating whether we should use async IO on this platform. /// . /// /// Returns false on Windows; otherwise true. public static bool UseAsyncIO => !OperatingSystem.IsWindows(); /// /// Opens an existing file for reading. /// /// The file to be opened for reading. /// A read-only on the specified path. public static FileStream OpenRead(string path) => new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, UseAsyncIO); /// /// Opens an existing file for writing. /// /// The file to be opened for writing. /// An unshared object on the specified path with Write access. public static FileStream OpenWrite(string path) => new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, UseAsyncIO); } }