Exemple #1
0
        public byte[] GetEntryContent(string entryName)
        {
            var entry = _entryTable[entryName];

            if (entry == null)
            {
                return(null);
            }

            var extractReader = new BinaryReader(File.Open(PackagePath, System.IO.FileMode.Open));

            var result = entry.IsCompressed
                ? GPakUtil.Decompress(GPakUtil.GetBytesFromFile(extractReader, entry.ContentOffset, entry.SizeInBytes))
                : GPakUtil.GetBytesFromFile(extractReader, entry.ContentOffset, entry.SizeInBytes);

            extractReader.Close();

            return(result);
        }
Exemple #2
0
        public void ExtractAll(string toDirectory = "")
        {
            if (toDirectory != "" && !Directory.Exists(toDirectory))
            {
                Directory.CreateDirectory(toDirectory);
            }

            var extractReader = new BinaryReader(File.Open(PackagePath, System.IO.FileMode.Open));

            foreach (var(name, entry) in _entryTable)
            {
                var writer = new BinaryWriter(File.Open(Path.Combine(toDirectory, name), System.IO.FileMode.Create));

                writer.Write(entry.IsCompressed
                    ? GPakUtil.Decompress(GPakUtil.GetBytesFromFile(extractReader, entry.ContentOffset, entry.SizeInBytes))
                    : GPakUtil.GetBytesFromFile(extractReader, entry.ContentOffset, entry.SizeInBytes));

                writer.Close();
            }

            extractReader.Close();
        }