public void WriteFileObject(FileWriter writer) { writer.WriteString(Name); writer.WriteInt32(Offset); writer.WriteInt32(Size); //writer.BaseStream.Position = Offset; //writer.WriteByteArray(Bytes); }
public void Close(bool write) { if (!write) { return; } var fileWriter = new FileWriter(); var headerSize = 5; fileWriter.WriteInt32(FileCount); for (int i = 0; i < FileCount; i++) { fileWriter.WriteString(this[i].Name); fileWriter.WriteInt32(this[i].Offset); fileWriter.WriteInt32(this[i].Size); headerSize += this[i].Name.Length + 9; } fileWriter.WriteByte(0x00); for (int i = 0; i < FileCount; i++) { fileWriter.Position = this[i].Offset; fileWriter.WriteByteArray(this[i].Bytes); } var uncompressed = ((MemoryStream)fileWriter.BaseStream).ToArray(); var compressedBody = LzmaUtils.Compress(uncompressed); fileWriter = new FileWriter(); fileWriter.WriteString("UnityWeb"); fileWriter.WriteInt32(3); fileWriter.WriteString("3.x.x"); fileWriter.WriteString("4.6.1f1"); fileWriter.WriteInt32(compressedBody.Length + 60); fileWriter.WriteInt32(60); fileWriter.WriteInt32(1); fileWriter.WriteInt32(1); fileWriter.WriteInt32(compressedBody.Length); fileWriter.WriteInt32(uncompressed.Length); fileWriter.WriteInt32(compressedBody.Length + 60); fileWriter.WriteInt32(headerSize); fileWriter.WriteByte(0x00); fileWriter.WriteByteArray(compressedBody); fileWriter.WriteByte(0x00); File.WriteAllBytes(FilePath, ((MemoryStream)fileWriter.BaseStream).ToArray()); this.CompressedSize = fileWriter.BaseStream.Length; }