示例#1
0
        /// <summary>
        /// Populates the contents of the table from a binary stream.
        /// </summary>
        /// <param name="reader">The binary reader used to read the data.</param>
        /// <returns>The number of bytes read.</returns>
        public int Deserialize(INTV.Shared.Utility.ASCIIBinaryReader reader)
        {
            GlobalForkTable forkTable = this;

            byte[] header    = reader.ReadBytes(Header.Length);
            var    bytesRead = header.Length;

            ushort globalForkNumber = 0;
            ushort numEntries       = reader.ReadUInt16();

            bytesRead += sizeof(ushort);

            int numChunksToRead = (int)Math.Ceiling((double)numEntries / 8);

            for (int i = 0; i < numChunksToRead; ++i)
            {
                var validEntriesMask = reader.ReadByte();
                ++bytesRead;
                for (int e = 0; e < 8; ++e)
                {
                    byte mask = (byte)(1 << e);
                    if ((mask & validEntriesMask) == mask)
                    {
                        var fork = Fork.Inflate(reader);
                        fork.FileSystem             = _fileSystem;
                        bytesRead                  += fork.DeserializeByteCount;
                        fork.GlobalForkNumber       = globalForkNumber;
                        forkTable[globalForkNumber] = fork;
                    }
                    ++globalForkNumber;
                }
            }
            return(bytesRead);
        }
示例#2
0
 /// <summary>
 /// Decompresses data describing a GlobalForkTable.
 /// </summary>
 /// <param name="reader">A binary data reader from which to extract the flattened table.</param>
 /// <param name="rawData">The data stream.</param>
 public static void DecompressData(INTV.Shared.Utility.ASCIIBinaryReader reader, System.IO.Stream rawData)
 {
     FileSystemHelpers.DecompressedFixedSizeCollection(reader, rawData, Header, Fork.FlatSizeInBytes, TableSize);
 }
示例#3
0
 /// <summary>
 /// Decompresses data describing a GlobalFileTable.
 /// </summary>
 /// <param name="reader">A binary data reader from which to extract the flattened table.</param>
 /// <param name="destination">Receives the decompressed data.</param>
 public static void DecompressData(INTV.Shared.Utility.ASCIIBinaryReader reader, System.IO.Stream destination)
 {
     FileSystemHelpers.DecompressedFixedSizeCollection(reader, destination, Header, LfsFileInfo.FlatSizeInBytes, TableSize);
 }