Beispiel #1
0
        public ArchiveFile(ArchiveFileInfo file)
        {
            File = file;
            Mode = OpenMode.Read;
            Size = (File.UncompressedSize > 0 ? File.UncompressedSize : File.DataSize);

            if (File.RomfsParent != null)
            {
                BaseStorage = File.RomfsParent.GetBaseStorage().Slice(File.DataOffset + File.RomfsParent.Header.DataOffset, File.DataSize);
            }
            else
            {
                BaseStorage = File.ArchiveParent.Slice(File.DataOffset, File.DataSize);
            }

            if (File.UncompressedSize > 0)
            {
                using (var deflate = new ZlibStream(BaseStorage.AsStream(), CompressionMode.Decompress, true))
                {
                    MemoryStream deflateStream = new MemoryStream();
                    deflate.CopyStream(deflateStream, File.UncompressedSize);
                    BaseStorage = deflateStream.AsStorage();
                }
            }
        }