Esempio n. 1
0
        /// <summary>
        /// returns the decompressed file
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="regionIndex"></param>
        /// <returns></returns>
        public byte[] GetFile(string filepath, int regionIndex = 0)
        {
            GetFileInformation(filepath, out long offset, out uint compSize, out uint decompSize, out bool regional, regionIndex);

            if (decompSize > 0 && decompSize != compSize)
            {
                var decompressed = ExtBinaryReader.DecompressZstd(GetSection(offset, compSize));
                if (decompressed.Length != decompSize)
                {
                    throw new InvalidDataException("Error decompressing file");
                }
                return(decompressed);
            }
            return(GetSection(offset, compSize));
        }
Esempio n. 2
0
        /// <summary>
        /// returns the decompressed file
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public byte[] GetFile(string filepath, int region = 0)
        {
            long Offset;
            uint CompSize, DecompSize;
            bool regional;

            GetFileInformation(filepath, out Offset, out CompSize, out DecompSize, out regional, region);

            if (DecompSize > 0 && DecompSize != CompSize)
            {
                var decompressed = ExtBinaryReader.DecompressZstd(GetSection(Offset, CompSize));
                if (decompressed.Length != DecompSize)
                {
                    throw new InvalidDataException("Error decompressing file");
                }
                return(decompressed);
            }
            return(GetSection(Offset, CompSize));
        }