-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFileInfoZip.cs
47 lines (43 loc) · 1.01 KB
/
FileInfoZip.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
42
43
44
45
46
47
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
namespace NbuExplorer
{
public class FileInfoZip : FileInfo
{
private long offset;
private long fileSize;
private int itemIndex;
public FileInfoZip(string sourcePath, ZipEntry ze, int itemIndex, long offset)
{
this.sourcePath = sourcePath;
this.offset = offset;
this.itemIndex = itemIndex;
this.Filename = Path.GetFileName(ze.Name);
this.FileTime = ze.DateTime;
this.fileSize = ze.Size;
}
public override long FileSize
{
get { return fileSize; }
}
public override void CopyToStream(Stream fstgt)
{
using (FileStream fs = File.OpenRead(sourcePath))
{
fs.Seek(offset, SeekOrigin.Begin);
ZipInputStream zs = new ZipInputStream(fs);
ZipEntry ze;
int index = 0;
while ((ze = zs.GetNextEntry()) != null)
{
if (itemIndex == index)
{
StreamUtils.CopyFromStreamToStream(zs, fstgt, ze.Size);
return;
}
index++;
}
}
}
}
}