public static BUNDLE Load(string path) { FileInfo fi = new FileInfo(path); Logger.LogToFile(Logger.LogLevel.Info, "{0}", path); BUNDLE bundle = new BUNDLE(); bundle.name = Path.GetFileNameWithoutExtension(path); bundle.extension = Path.GetExtension(path); bundle.location = Path.GetDirectoryName(path) + "\\"; using (var br = new BinaryReader(fi.OpenRead())) { if (br.ReadByte() != 98 || br.ReadByte() != 110 || br.ReadByte() != 100 || br.ReadByte() != 50) { Logger.LogToFile(Logger.LogLevel.Error, "{0} isn't a valid BUNDLE file", path); return null; } bundle.version = (int)br.ReadInt32(); br.ReadInt32(); bundle.size = (int)br.ReadInt32(); int fileCount = (int)br.ReadInt32(); int tableOffset = (int)br.ReadInt32(); int headerOffset = (int)br.ReadInt32(); int bodyOffset = (int)br.ReadInt32(); int dataEnd = (int)br.ReadInt32(); br.ReadInt32(); bundle.flags = (int)br.ReadInt32(); br.ReadInt32(); for (int i = 0; i < fileCount; i++) { var entry = new BUNDLEEntry { Name = i.ToString("00000") }; Console.WriteLine("{0}:", entry.Name); br.ReadInt32(); // CRC Console.WriteLine("{0} == 0", br.ReadInt32()); br.ReadInt32(); // LinkID Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderSize = ((int)br.ReadInt32() << 8) >> 8; entry.DataSize = ((int)br.ReadInt32() << 8) >> 8; Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderSizeCompressed = (int)br.ReadInt32(); entry.DataSizeCompressed = (int)br.ReadInt32(); Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderOffset = headerOffset + (int)br.ReadInt32(); entry.DataOffset = bodyOffset + (int)br.ReadInt32(); Console.WriteLine("{0} == 0", br.ReadInt32()); Console.WriteLine("{0} == 0", br.ReadInt32()); entry.Type = br.ReadInt16(); entry.Count = br.ReadInt16(); Console.WriteLine("{0} == 0", br.ReadInt32()); bundle.Contents.Add(entry); } } return bundle; }
public static BUNDLE Load(string path) { FileInfo fi = new FileInfo(path); Logger.LogToFile(Logger.LogLevel.Info, "{0}", path); BUNDLE bundle = new BUNDLE { Name = Path.GetFileNameWithoutExtension(path), Extension = Path.GetExtension(path), Location = Path.GetDirectoryName(path) }; using (BinaryReader br = new BinaryReader(fi.OpenRead())) { if (br.ReadByte() != 0x62 || br.ReadByte() != 0x6e || br.ReadByte() != 0x64 || br.ReadByte() != 0x32) { Logger.LogToFile(Logger.LogLevel.Error, "{0} isn't a valid BUNDLE file", path); return(null); } bundle.Version = br.ReadInt32(); br.ReadInt32(); bundle.Size = br.ReadInt32(); int fileCount = br.ReadInt32(); br.ReadInt32(); // table offset int headerOffset = br.ReadInt32(); int bodyOffset = br.ReadInt32(); br.ReadInt32(); // data end br.ReadInt32(); bundle.Flags = br.ReadInt32(); br.ReadInt32(); for (int i = 0; i < fileCount; i++) { BUNDLEEntry entry = new BUNDLEEntry { Name = i.ToString("00000") }; Console.WriteLine("{0}:", entry.Name); br.ReadInt32(); // CRC Console.WriteLine("{0} == 0", br.ReadInt32()); br.ReadInt32(); // LinkID Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderSize = ((int)br.ReadInt32() << 8) >> 8; entry.DataSize = ((int)br.ReadInt32() << 8) >> 8; Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderSizeCompressed = (int)br.ReadInt32(); entry.DataSizeCompressed = (int)br.ReadInt32(); Console.WriteLine("{0} == 0", br.ReadInt32()); entry.HeaderOffset = headerOffset + (int)br.ReadInt32(); entry.DataOffset = bodyOffset + (int)br.ReadInt32(); Console.WriteLine("{0} == 0", br.ReadInt32()); Console.WriteLine("{0} == 0", br.ReadInt32()); entry.Type = br.ReadInt16(); entry.Count = br.ReadInt16(); Console.WriteLine("{0} == 0", br.ReadInt32()); bundle.Contents.Add(entry); } } return(bundle); }