Ejemplo n.º 1
0
        private void ReadEntries()
        {
            _entryTable = new PakEntryTable();

            using (var reader = new BinaryReader(_stream, Encoding.UTF8, true))
            {
                _stream.Seek(_indexOffset, SeekOrigin.Begin);
                MountPoint = reader.ReadFString();
                int fileCount = reader.ReadInt32();
                for (int i = 0; i < fileCount; i++)
                {
                    string           fileName       = reader.ReadFString();
                    long             metadataOffset = _stream.Position;
                    PakEntryMetadata metadata       = ReadEntryMetadata(reader);
                    metadata.MetadataOffset = metadataOffset;
                    metadata.FileName       = fileName;

                    _entryTable.Add(metadata);
                }
            }
        }
Ejemplo n.º 2
0
        private void ReadEntries(string encryptionKey)
        {
            if (!IsIndexEncrypted)
            {
                ReadEntries();
                return;
            }

            _entryTable = new PakEntryTable();

            byte[] indexBlock = DecryptIndexBlock(encryptionKey);

            using (var reader = new BinaryReader(new MemoryStream(indexBlock)))
            {
                try
                {
                    MountPoint = reader.ReadFString();
                    int fileCount = reader.ReadInt32();
                    for (int i = 0; i < fileCount; i++)
                    {
                        string           fileName       = reader.ReadFString();
                        long             metadataOffset = reader.BaseStream.Position;
                        PakEntryMetadata metadata       = ReadEntryMetadata(reader);
                        metadata.MetadataOffset = metadataOffset + _indexOffset;
                        metadata.FileName       = fileName;

                        _entryTable.Add(metadata);
                    }
                }
                catch (ArgumentOutOfRangeException) // reader.ReadFString will throw this if MountPoint cannot be read
                {
                    _entryTable = null;
                    throw new IncorrectEncryptionKeyException();
                }
            }
        }