From 559fa4b53d014e375f450f4b611e9fc92a5b843d Mon Sep 17 00:00:00 2001 From: AdAstra-LD <76622070+AdAstra-LD@users.noreply.github.com> Date: Sun, 5 May 2024 16:04:26 +0200 Subject: [PATCH] Extracted common DSUtils CreateDecompressProcess method --- DS_Map/DSUtils.cs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/DS_Map/DSUtils.cs b/DS_Map/DSUtils.cs index 1a580f4..6b82af8 100644 --- a/DS_Map/DSUtils.cs +++ b/DS_Map/DSUtils.cs @@ -48,16 +48,13 @@ namespace DSPRE { } } public static bool Decompress(string path) { - Process decompress = new Process(); - decompress.StartInfo.FileName = @"Tools\blz.exe"; - decompress.StartInfo.Arguments = @" -d " + '"' + path + '"'; - decompress.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - decompress.StartInfo.CreateNoWindow = true; + Process decompress = CreateDecompressProcess(path); decompress.Start(); decompress.WaitForExit(); return new FileInfo(RomInfo.arm9Path).Length > 0xBC000; } + public static bool Compress(string path) { Process compress = new Process(); compress.StartInfo.FileName = @"Tools\blz.exe"; @@ -290,17 +287,22 @@ namespace DSPRE { File.Copy(overlayFilePath, overlayFilePath + backupSuffix); } - Process unpack = new Process(); - unpack.StartInfo.FileName = @"Tools\blz.exe"; - String arguments = "-d " + '"' + overlayFilePath + '"'; - unpack.StartInfo.Arguments = arguments; - Application.DoEvents(); - unpack.StartInfo.WindowStyle = ProcessWindowStyle.Normal; - unpack.StartInfo.CreateNoWindow = false; - unpack.Start(); - unpack.WaitForExit(); - return unpack.ExitCode; + Process decompress = DSUtils.CreateDecompressProcess(overlayFilePath); + decompress.Start(); + decompress.WaitForExit(); + return decompress.ExitCode; } + + public static Process CreateDecompressProcess(string path) { + Process decompress = new Process(); + decompress.StartInfo.FileName = @"Tools\blz.exe"; + decompress.StartInfo.Arguments = @" -d " + '"' + path + '"'; + decompress.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + decompress.StartInfo.CreateNoWindow = true; + return decompress; + + } + public static int CompressOverlay(int overlayNumber) { string overlayFilePath = GetOverlayPath(overlayNumber);