Skip to content

Commit

Permalink
unzip zipped index
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Jan 29, 2022
1 parent 9a895b6 commit c277565
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions IndexHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Xml;

Expand All @@ -11,6 +12,25 @@ public static XmlDocument LoadIndex (String path)
{
byte[] data = File.ReadAllBytes(path);
Crypt.decrypt(data, data.Length);
// check if the file is a zip file
if ((data[0] == 0x50) && (data[1] == 0x4b))
{
byte[] tempData;
using (var stream = new MemoryStream(data))
{
using (ZipArchive z = new ZipArchive(stream))
{
ZipArchiveEntry entry = z.GetEntry("index");
tempData = new byte[entry.Length];
using (var entryStream = entry.Open())
{
entryStream.Read(tempData, 0, (int)entry.Length);
}
}
}
data = tempData;
}

int i = data.Length - 1;
while (data[i] == 0)
{
Expand Down

0 comments on commit c277565

Please sign in to comment.