public void Extract(PKEntry file, string destination) { if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } using (BinaryWriter bw = new BinaryWriter(new FileStream(destination + "\\" + file.Name, FileMode.Create))) using (FileStream fs = new FileStream(location + name + ".pk", FileMode.Open)) { fs.Seek(file.Offset, SeekOrigin.Begin); if (file.Unknown != 0) { using (LSZZDecompress ds = new LSZZDecompress(fs)) { byte[] buff = new byte[file.Unknown]; ds.Read(buff, 0, file.Size); bw.Write(buff); buff = null; } } else { byte[] buff = new byte[file.Size]; fs.Read(buff, 0, file.Size); bw.Write(buff); buff = null; } } }
public void Extract(PKEntry file, string destination) { if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } using (var bw = new BinaryWriter(new FileStream(destination + "\\" + file.Name, FileMode.Create))) { using (var fs = new FileStream(this.location + this.name + ".pk", FileMode.Open)) { fs.Seek(file.Offset, SeekOrigin.Begin); if (file.Unknown != 0) { using (var ds = new LSZZDecompress(fs)) { var buff = new byte[file.Unknown]; ds.Read(buff, 0, file.Size); bw.Write(buff); buff = null; } } else { var buff = new byte[file.Size]; fs.Read(buff, 0, file.Size); bw.Write(buff); buff = null; } } } }