/
NativeFile.cs
41 lines (36 loc) · 1.22 KB
/
NativeFile.cs
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
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
using Files.Core.Storage;
using Files.Core.Storage.ExtendableStorage;
using Files.Core.Storage.LocatableStorage;
using Files.Core.Storage.ModifiableStorage;
using Files.Core.Storage.NestedStorage;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Files.App.Storage.NativeStorage
{
/// <inheritdoc cref="IFile"/>
public class NativeFile : NativeStorable<FileInfo>, ILocatableFile, IModifiableFile, IFileExtended, INestedFile
{
public NativeFile(FileInfo fileInfo, string? name = null)
: base(fileInfo, name)
{
}
public NativeFile(string path, string? name = null)
: this(new FileInfo(path), name)
{
}
/// <inheritdoc/>
public virtual Task<Stream> OpenStreamAsync(FileAccess access, CancellationToken cancellationToken = default)
{
return OpenStreamAsync(access, FileShare.None, cancellationToken);
}
/// <inheritdoc/>
public virtual Task<Stream> OpenStreamAsync(FileAccess access, FileShare share = FileShare.None, CancellationToken cancellationToken = default)
{
var stream = File.Open(Path, FileMode.Open, access, share);
return Task.FromResult<Stream>(stream);
}
}
}