public Stream GetStream() { var ms = new MemoryStream(); m_file.Export(ms); ms.Position = 0; return(ms); }
/// <summary> /// Exports a file. /// </summary> public void Export(IArchiveFile file, string fileName) { if (file is IArchiveBinaryFile) { var binFile = (IArchiveBinaryFile)file; // export var ms = new MemoryStream(); file.Export(ms); ms.Position = 0; var buf = new byte[ms.Length]; ms.Position = 0; ms.Read(buf, 0, buf.Length); // decrypt... if (binFile.IsEncrypted) { var qq = GTA5Hash.CalculateHash(binFile.Name); var gg = (qq + (uint)binFile.UncompressedSize + (101 - 40)) % 0x65; // TODO: if archive encrypted with AES, use AES key... buf = GTA5Crypto.Decrypt(buf, GTA5Constants.PC_NG_KEYS[gg]); } // decompress... if (binFile.IsCompressed) { var def = new DeflateStream(new MemoryStream(buf), CompressionMode.Decompress); var bufnew = new byte[binFile.UncompressedSize]; def.Read(bufnew, 0, (int)binFile.UncompressedSize); buf = bufnew; } File.WriteAllBytes(fileName, buf); } else { file.Export(fileName); } }