private static RootIndexBlock ReadRootBlock(IViewableData file, BlockInfoHeader rootBlockInfo) { using (var reader = new BinaryReader(GetBlockView(rootBlockInfo, file))) { return(RootIndexBlock.FromReader(reader)); } }
protected ArchiveFileBase(IViewableData file, ArchiveHeader header, BlockInfoHeader[] blockInfoHeaders, RootIndexBlock rootIndex) { File = file; Header = header; BlockPointers = blockInfoHeaders; RootIndex = rootIndex; }
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); } }
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); }
public ArchiveFile(IViewableData file, ArchiveHeader header, BlockInfoHeader[] blockInfoHeaders, RootIndexBlock rootIndex) : base(file, header, blockInfoHeaders, rootIndex) { _dataEntries = ReadDataHeaders(GetBlockReader(rootIndex.BlockIndex)); }