コード例 #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)
        {
            GlobalFileTable fileTable = this;

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

            ushort globalFileNumber = 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 file = LfsFileInfo.Inflate(reader);
                        file.FileSystem             = _fileSystem;
                        bytesRead                  += file.DeserializeByteCount;
                        file.GlobalFileNumber       = globalFileNumber;
                        fileTable[globalFileNumber] = file;
                    }
                    ++globalFileNumber;
                }
            }
            return(bytesRead);
        }
コード例 #2
0
ファイル: FileSystem.cs プロジェクト: intvsteve/VINTage
 /// <summary>
 /// Initializes a new instance of the Locutus File System v2.
 /// </summary>
 /// <param name="origin">Origin of the file system.</param>
 public FileSystem(FileSystemOrigin origin)
 {
     Origin      = origin;
     Directories = new GlobalDirectoryTable(this);
     Files       = new GlobalFileTable(this);
     Forks       = new GlobalForkTable(this);
 }