public void Write(AssetsWriter writer) { writer.WriteBEInt64(Offset); writer.WriteBEInt64(Size); writer.WriteBEUInt32(_flags); writer.WriteCString(Filename); }
public void Write(AssetsWriter writer, byte[] compressedData) { if (fileVersion != 6) { throw new NotSupportedException("File version is not supported"); } //basic header stuff writer.WriteCString(signature); writer.WriteBEInt32(fileVersion); // TODO ADD // WriteDirectory to a MemoryStream // Check length of the resultant byte array, should be = UncompressedLength // Compress it // Write compressed length MemoryStream s = new MemoryStream(); using (AssetsWriter w = new AssetsWriter(s)) { WriteDirectory(w); } int uncompressedLength = (int)s.Length; // todo var compressedMetadata = LZ4.LZ4Codec.EncodeHC(s.ToArray(), 0, uncompressedLength); BundleSize += compressedMetadata.Length; writer.WriteCString(PlayerVersion); writer.WriteCString(EngineVersion); writer.WriteBEInt64(BundleSize); // compressedSize is actually the size of the METADATA byte array // The one with the Entries and BlockInfos + unknown directory header writer.WriteBEInt32(compressedMetadata.Length); writer.WriteBEInt32(uncompressedLength); writer.WriteBEUInt32(flags); if (!IsDirectoryAtEnd(flags)) { // Actually write the directory information to the file writer.Write(compressedMetadata); } // Now write the actual data the BlockInfos use writer.Write(compressedData); if (IsDirectoryAtEnd(flags)) { // Actually write the directory information to the file writer.Write(compressedMetadata); } }
public void Write(AssetsWriter writer) { writer.WriteBEUInt32(UncompressedSize); writer.WriteBEUInt32(CompressedSize); writer.WriteBEUInt16(_flags); }