-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathZipFile.cs
More file actions
45 lines (43 loc) · 1.38 KB
/
ZipFile.cs
File metadata and controls
45 lines (43 loc) · 1.38 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
using AlphaTab.Importer;
using Haxe.Zip;
using Phase;
namespace AlphaTab.IO
{
internal partial class ZipFile
{
/// <summary>
/// Load a complete ZipFile to the memory.
/// </summary>
/// <param name="s">the binary source to read from.</param>
/// <returns></returns>
public void Load(IReadable s)
{
try
{
var haxeInput = new ReadableInput(s);
var reader = new Reader(haxeInput);
var entries = reader.Read();
foreach (var entry in entries)
{
string fullName = entry.FileName;
if (FileFilter == null || FileFilter(fullName))
{
var i = fullName.LastIndexOf("/");
var name = i >= 0 ? fullName.Substring(i + 1) : fullName;
var data = entry.Data.GetData();
Entries.Add(new ZipEntry
{
FullName = fullName,
FileName = name,
Data = Script.Write<byte[]>("data")
});
}
}
}
catch
{
throw new UnsupportedFormatException("Not a valid zip file");
}
}
}
}