Skip to content

Instantly share code, notes, and snippets.

@splhack
Created January 31, 2015 01:03
Show Gist options
  • Select an option

  • Save splhack/bbb366c1a193d06ed1e2 to your computer and use it in GitHub Desktop.

Select an option

Save splhack/bbb366c1a193d06ed1e2 to your computer and use it in GitHub Desktop.
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read)) {
using (var br = new BinaryReader(fs, new ASCIIEncoding())) {
// UnityWeb
while (br.ReadChar() != 0) {
;
}
// format
br.ReadInt32();
// player version
while (br.ReadChar() != 0) {
;
}
// engine version
while (br.ReadChar() != 0) {
;
}
// file size
br.ReadInt32();
// data offset
var bytes = br.ReadBytes(4);
int dataOffset = bytes[3] | (bytes[2] << 8) | (bytes[1] << 16) | (bytes[0] << 24);
br.BaseStream.Seek(dataOffset, SeekOrigin.Begin);
// LZMA props
br.ReadBytes(5);
// size
size = (int) br.ReadInt64();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment