コード例 #1
0
 private static RootIndexBlock ReadRootBlock(IViewableData file, BlockInfoHeader rootBlockInfo)
 {
     using (var reader = new BinaryReader(GetBlockView(rootBlockInfo, file)))
     {
         return(RootIndexBlock.FromReader(reader));
     }
 }
コード例 #2
0
 protected ArchiveFileBase(IViewableData file, ArchiveHeader header,
                           BlockInfoHeader[] blockInfoHeaders, RootIndexBlock rootIndex)
 {
     File          = file;
     Header        = header;
     BlockPointers = blockInfoHeaders;
     RootIndex     = rootIndex;
 }
コード例 #3
0
        public IndexFile(IViewableData file, ArchiveHeader header,
                         BlockInfoHeader[] blockInfoHeaders, RootIndexBlock rootIndex)
            : base(file, header, blockInfoHeaders, rootIndex)
        {
            RootFolder = new FolderEntry("", this,
                                         new BinaryReader(GetBlockView(rootIndex.BlockIndex), Encoding.UTF8));

            using (var fileStream = System.IO.File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (var sha = SHA1.Create())
                {
                    _fileHash = sha.ComputeHash(fileStream);
                }
        }
コード例 #4
0
        public static RootIndexBlock FromReader(BinaryReader reader)
        {
            var ret = new RootIndexBlock()
            {
                ArchiveType = (ArchiveType)reader.ReadUInt32(),
                Version     = reader.ReadUInt32(),
            };

            if (ret.Version == 1)
            {
                ret.BuildNumber = reader.ReadUInt32();
            }
            else if (ret.Version == 2)
            {
                ret.BlockCount = reader.ReadUInt32();
            }
            else
            {
                throw new InvalidDataException($"Unknown file version {ret.Version} for archive type {ret.ArchiveType}");
            }

            ret.BlockIndex = reader.ReadInt32();
            return(ret);
        }
コード例 #5
0
ファイル: ArchiveFile.cs プロジェクト: ahoiahoi/Nexus.Archive
 public ArchiveFile(IViewableData file, ArchiveHeader header,
                    BlockInfoHeader[] blockInfoHeaders, RootIndexBlock rootIndex)
     : base(file, header, blockInfoHeaders, rootIndex)
 {
     _dataEntries = ReadDataHeaders(GetBlockReader(rootIndex.BlockIndex));
 }