using System.IO;
namespace MediaBrowser.Model.IO
{
///
/// Helper class to create async s.
///
public static class AsyncFile
{
///
/// Gets the default for reading files async.
///
public static FileStreamOptions ReadOptions => new FileStreamOptions()
{
Options = FileOptions.Asynchronous
};
///
/// Gets the default for writing files async.
///
public static FileStreamOptions WriteOptions => new FileStreamOptions()
{
Mode = FileMode.OpenOrCreate,
Access = FileAccess.Write,
Share = FileShare.None,
Options = FileOptions.Asynchronous
};
///
/// 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, FileOptions.Asynchronous);
///
/// 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, FileOptions.Asynchronous);
}
}