コード例 #1
0
ファイル: Extensions.cs プロジェクト: Lion1616/ProjectP
 public static byte[] DecompressZLib(this byte[] @this)
 {
     using (var zlib = new ZlibStream(new MemoryStream(@this), CompressionMode.Decompress))
     {
         return(zlib.ReadToEnd());
     }
 }
コード例 #2
0
        /// <summary>
        ///     Extracts information about all file indicies from the archive.
        /// </summary>
        /// <returns>A list of all file indicies found in the archive.</returns>
        private IEnumerable <ArchiveIndex> ExtractIndices()
        {
            var parser = new PickleParser();

            // Open archive in read-only mode.
            using (var fs = _info.OpenRead()) {
                // Read header line and split it at whitespace.
                var header   = fs.ReadLine();
                var splitted = header.Split((char)0x20);
                // Retrieve hexadecimal offset and convert it to an integer value.
                var offset = Convert.ToInt32(splitted[1], 16);
                // Seek to the determined offset and read archive structure.
                fs.Seek(offset, SeekOrigin.Begin);
                using (var stream = new ZlibStream(fs, CompressionMode.Decompress)) {
                    var decompressed = stream.ReadToEnd();
                    // Unpickle the decompressed data
                    var deserialized = parser.Unpickle(decompressed);
                    if (Version != 3)
                    {
                        return(deserialized);
                    }
                    // If this is an RPA-3.0 archive additionally calculate the deobfuscation key.
                    CalculateDeobfuscationKey(splitted);
                    // Deobfuscate archive indicies.
                    deserialized = Deobfuscate(deserialized);
                    return(deserialized);
                }
            }
        }
コード例 #3
0
        private static string decompressFile(string inputFile)
        {
            var outputFile = inputFile + ".raw";
            var sr         = File.OpenRead(inputFile);
            var s          = new ZlibStream(sr, CompressionMode.Decompress);
            var bytes      = s.ReadToEnd().ToArray();

            File.WriteAllBytes(outputFile, bytes);
            s.Close();
            sr.Close();
            return(outputFile);
        }
コード例 #4
0
ファイル: DlmReader.cs プロジェクト: Urtimal/BlueTofuEngine
        private static void decompressDlm(string filepath, string outputFolder)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            var mapId    = Path.GetFileNameWithoutExtension(filepath);
            var or       = File.OpenRead(filepath);
            var s        = new ZlibStream(or, CompressionMode.Decompress);
            var mapBytes = s.ReadToEnd();

            File.WriteAllBytes(Path.Combine(outputFolder, mapId + ".map"), mapBytes.ToArray());
            s.Close();
            or.Close();
        }