You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Model/IO/AsyncFile.cs

28 lines
1.1 KiB

using System;
using System.IO;
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Helper class to create async <see cref="FileStream" />s.
/// </summary>
public static class AsyncFile
{
/// <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);
}
}