-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
29 lines (25 loc) · 971 Bytes
/
Program.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
//Written for games on 001 Game Creator. https://001gamecreator.com/
using System.IO.Compression;
BinaryReader br = new(File.OpenRead(args[0]));
Directory.CreateDirectory(Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]));
br.BaseStream.Position += 8;
int fileCount = br.ReadInt32();
for (int i = 0; i < fileCount; i++)
{
string name = new(br.ReadChars(br.ReadInt32()));
int sizeUncompressed = br.ReadInt32();
int size = br.ReadInt32();
using FileStream FS = File.Create(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + name);
if (sizeUncompressed == -1)
{
BinaryWriter bw = new(FS);
bw.Write(br.ReadBytes(size));
}
else
{
br.ReadInt16();
using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes(size - 2)), CompressionMode.Decompress))
ds.CopyTo(FS);
}
FS.Close();
}