Пример #1
0
 public Archive()
 {
     this.header      = new Header();
     this.fileEntries = null;
     this.blockSizes  = null;
     this.filePaths   = null;
 }
Пример #2
0
 private static void DebugLogBlockSizes(BlockSizeList blockSizes, int count)
 {
     count = Math.Min(blockSizes.Length, count);
     for (int i = 0; i < count; i++)
     {
         DebugLog($"blockSizes[{i}] = {blockSizes[i]}");
     }
 }
Пример #3
0
        public Archive(Stream stream, bool keepOpen = false)
        {
            this.streamIn = stream;
            this.keepOpen = keepOpen;

            if (!Header.IsValid(streamIn))
            {
                throw new InvalidArchiveException();
            }

            header = new Header(streamIn);
            DebugLog(header);

            DebugLogPosition(streamIn.Position);

            fileEntries = new FileList(streamIn, header.numFiles);
            DebugLogFileEntries(fileEntries, 5);

            DebugLogPosition(streamIn.Position);

            int length = (int)(header.dataOffset - streamIn.Position);

            length -= (header.flags.HasFlag(ArchiveFlags.Encrypted) ? 0x20 : 0x00);

            blockSizes = new BlockSizeList(streamIn, length, header.maxBlockSize);
            DebugLogBlockSizes(blockSizes, 5);

            DebugLogPosition(streamIn.Position);

            filePaths = new List <string>();
            using (var reader = new StreamReader(ExtractFile(fileEntries[0]))) {
                while (!reader.EndOfStream)
                {
                    filePaths.Add(reader.ReadLine());
                }
            }
        }