-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathFileStreamFactory.cs
More file actions
70 lines (55 loc) · 2.74 KB
/
FileStreamFactory.cs
File metadata and controls
70 lines (55 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Microsoft.Win32.SafeHandles;
namespace System.IO.Abstractions
{
#if FEATURE_SERIALIZABLE
[Serializable]
#endif
internal sealed class FileStreamFactory : IFileStreamFactory
{
/// <summary>
/// Base factory class for creating a <see cref="FileSystemStream"/>
/// </summary>
public FileStreamFactory(IFileSystem fileSystem)
{
FileSystem = fileSystem;
}
/// <inheritdoc />
public IFileSystem FileSystem { get; }
/// <inheritdoc />
public FileSystemStream New(SafeFileHandle handle, FileAccess access)
=> new FileStreamWrapper(new FileStream(handle, access));
/// <inheritdoc />
public FileSystemStream New(SafeFileHandle handle, FileAccess access, int bufferSize)
=> new FileStreamWrapper(new FileStream(handle, access, bufferSize));
/// <inheritdoc />
public FileSystemStream New(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
=> new FileStreamWrapper(new FileStream(handle, access, bufferSize, isAsync));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode)
=> new FileStreamWrapper(new FileStream(path, mode));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode, FileAccess access)
=> new FileStreamWrapper(new FileStream(path, mode, access));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share)
=> new FileStreamWrapper(new FileStream(path, mode, access, share));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
=> new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
=> new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize, useAsync));
/// <inheritdoc />
public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
FileOptions options)
=> new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize, options));
#if FEATURE_FILESTREAM_OPTIONS
/// <inheritdoc />
public FileSystemStream New(string path, FileStreamOptions options)
=> new FileStreamWrapper(new FileStream(path, options));
#endif
/// <inheritdoc />
public FileSystemStream Wrap(FileStream fileStream)
=> new FileStreamWrapper(fileStream);
}
}