-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZipFile.cs
More file actions
52 lines (42 loc) · 1.98 KB
/
ZipFile.cs
File metadata and controls
52 lines (42 loc) · 1.98 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
using System.IO.Compression;
namespace Ramstack.FileSystem.Zip;
/// <summary>
/// Represents a file within a ZIP archive.
/// </summary>
[Obsolete]
internal sealed class ZipFile : VirtualFile
{
private readonly ZipFileSystem _fileSystem;
private readonly ZipArchiveEntry _entry;
/// <inheritdoc />
public override IVirtualFileSystem FileSystem => _fileSystem;
/// <summary>
/// Initializes a new instance of the <see cref="ZipFile"/> class.
/// </summary>
/// <param name="fileSystem">The file system associated with this file.</param>
/// <param name="path">The path of the file.</param>
/// <param name="entry">The ZIP archive entry representing the file.</param>
public ZipFile(ZipFileSystem fileSystem, string path, ZipArchiveEntry entry) : base(path) =>
(_fileSystem, _entry) = (fileSystem, entry);
/// <inheritdoc />
protected override ValueTask<VirtualNodeProperties?> GetPropertiesCoreAsync(CancellationToken cancellationToken)
{
var properties = VirtualNodeProperties.CreateFileProperties(default, default, lastWriteTime: _entry.LastWriteTime, _entry.Length);
return new ValueTask<VirtualNodeProperties?>(properties);
}
/// <inheritdoc />
protected override ValueTask<bool> ExistsCoreAsync(CancellationToken cancellationToken) =>
new ValueTask<bool>(true);
/// <inheritdoc />
protected override ValueTask<Stream> OpenReadCoreAsync(CancellationToken cancellationToken) =>
new ValueTask<Stream>(_entry.Open());
/// <inheritdoc />
protected override ValueTask<Stream> OpenWriteCoreAsync(CancellationToken cancellationToken) =>
default;
/// <inheritdoc />
protected override ValueTask WriteCoreAsync(Stream stream, bool overwrite, CancellationToken cancellationToken) =>
default;
/// <inheritdoc />
protected override ValueTask DeleteCoreAsync(CancellationToken cancellationToken) =>
default;
}