Exemple #1
0
 public void Write(AssetsWriter writer)
 {
     writer.WriteBEInt32(MetadataSize);
     writer.WriteBEInt32(FileSize);
     writer.WriteBEInt32(Version);
     writer.WriteBEInt32(ObjectDataOffset);
     writer.Write(IsBigEndian);
     writer.AlignTo(4);
     //writer.Write(new byte[3]);
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        private void WriteDirectory(AssetsWriter writer)
        {
            //unknown?
            writer.Write(_directoryUnknown);
            writer.WriteBEInt32(BlockInfos.Count);

            for (int i = 0; i < BlockInfos.Count; i++)
            {
                BlockInfos[i].Write(writer);
            }

            writer.WriteBEInt32(Entries.Count);
            for (int i = 0; i < Entries.Count; i++)
            {
                Entries[i].Write(writer);
            }
        }