From 24fa428ca37e385b9b85dc8b959c0d513e9074d3 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Sun, 18 Mar 2018 22:16:45 +0300 Subject: Minor fixes --- MainForm.cs | 1 + Properties/AssemblyInfo.cs | 4 ++-- WorkerForm.cs | 47 +++++++++++++++++++++++++++++----------------- hakchi_gui.csproj | 16 ++++++++-------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 13ed0579..d6b2c9de 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1726,6 +1726,7 @@ namespace com.clusterrr.hakchi_gui { try { + Thread.Sleep(5000); showProcess.WaitForExit(); } catch { } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 5e0a89e7..3b5ec96d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ using System.Resources; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.30.14")] -[assembly: AssemblyFileVersion("2.0.30.14")] +[assembly: AssemblyVersion("2.0.30.15")] +[assembly: AssemblyFileVersion("2.0.30.15")] [assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/WorkerForm.cs b/WorkerForm.cs index 2b353e90..1d97593a 100644 --- a/WorkerForm.cs +++ b/WorkerForm.cs @@ -478,7 +478,8 @@ namespace com.clusterrr.hakchi_gui { // Unknown MD5? Hmm... Lets extract ramfs and check keyfile! string kernelDumpTemp = Path.Combine(tempDirectory, "kernel.img"); - Directory.CreateDirectory(tempDirectory); + if (!Directory.Exists(tempDirectory)) + Directory.CreateDirectory(tempDirectory); File.WriteAllBytes(kernelDumpTemp, kernel); UnpackRamfs(kernelDumpTemp); var key = File.ReadAllBytes(Path.Combine(ramfsDirectory, "key-file")); @@ -514,8 +515,8 @@ namespace com.clusterrr.hakchi_gui if (!matchedKernels.Contains(ConfigIni.ConsoleType)) throw new Exception(Resources.InvalidConsoleSelected + " " + matchedKernels.First()); } - - Directory.CreateDirectory(Path.GetDirectoryName(KernelDumpPath)); + if (!Directory.Exists(Path.GetDirectoryName(KernelDumpPath))) + Directory.CreateDirectory(Path.GetDirectoryName(KernelDumpPath)); if (!File.Exists(KernelDumpPath)) File.WriteAllBytes(KernelDumpPath, kernel); if (!string.IsNullOrEmpty(dumpPath)) @@ -658,7 +659,8 @@ namespace com.clusterrr.hakchi_gui SetProgress(maxProgress, maxProgress); SetStatus(Resources.Done); - Directory.CreateDirectory(Path.GetDirectoryName(NandDump)); + if (!Directory.Exists(Path.GetDirectoryName(NandDump))) + Directory.CreateDirectory(Path.GetDirectoryName(NandDump)); File.WriteAllBytes(NandDump, kernel); } @@ -901,8 +903,8 @@ namespace com.clusterrr.hakchi_gui tempGamesDirectory = Path.Combine(tempDirectory, "games"); if (exportGames) tempGamesDirectory = Path.Combine(tempGamesDirectory, SubConsoleDirectory); - Directory.CreateDirectory(tempDirectory); - Directory.CreateDirectory(tempGamesDirectory); + if (!Directory.Exists(tempGamesDirectory)) + Directory.CreateDirectory(tempGamesDirectory); File.WriteAllBytes(Path.Combine(tempGamesDirectory, ".repair.flag"), new byte[0]); Dictionary originalGames = new Dictionary(); var stats = new GamesTreeStats(); @@ -956,7 +958,8 @@ namespace com.clusterrr.hakchi_gui SetStatus(Resources.WritingUSB); maxProgress = (int)(stats.TotalSize / 1024 / 1024 + 20); SetProgress(progress, maxProgress); - Directory.CreateDirectory(exportDirectory); + if (!Directory.Exists(exportDirectory)) + Directory.CreateDirectory(exportDirectory); string lastDirectory = null; long pos = 0; if (!ExecuteTool("rsync.exe", $"-ac --delete --progress --exclude=title.fnt --exclude=copyright.fnt \"{cygwinPath(tempGamesDirectory)}\" \"{cygwinPath(exportDirectory)}\"", @@ -1234,9 +1237,12 @@ namespace com.clusterrr.hakchi_gui private void UnpackRamfs(string kernelPath = null) { - Directory.CreateDirectory(tempDirectory); - Directory.CreateDirectory(kernelDirectory); - Directory.CreateDirectory(ramfsDirectory); + if (!Directory.Exists(tempDirectory)) + Directory.CreateDirectory(tempDirectory); + if (!Directory.Exists(kernelDirectory)) + Directory.CreateDirectory(kernelDirectory); + if (!Directory.Exists(ramfsDirectory)) + Directory.CreateDirectory(ramfsDirectory); string tempKernelDump = Path.Combine(tempDirectory, "kernel.img"); if ((kernelPath ?? KernelDumpPath) != tempKernelDump) File.Copy(kernelPath ?? KernelDumpPath, tempKernelDump, true); @@ -1276,7 +1282,8 @@ namespace com.clusterrr.hakchi_gui if (hmodsInstall != null && hmodsInstall.Count() > 0) { - Directory.CreateDirectory(tempHmodsDirectory); + if (!Directory.Exists(tempHmodsDirectory)) + Directory.CreateDirectory(tempHmodsDirectory); foreach (var hmod in hmodsInstall) { var modName = hmod + ".hmod"; @@ -1297,7 +1304,8 @@ namespace com.clusterrr.hakchi_gui } if (hmodsUninstall != null && hmodsUninstall.Count() > 0) { - Directory.CreateDirectory(tempHmodsDirectory); + if (!Directory.Exists(tempHmodsDirectory)) + Directory.CreateDirectory(tempHmodsDirectory); var mods = new StringBuilder(); foreach (var hmod in hmodsUninstall) mods.AppendFormat("{0}.hmod\n", hmod); @@ -1370,7 +1378,8 @@ namespace com.clusterrr.hakchi_gui var originalCode = game.Code; var desktopFilePath = Path.Combine(desktopEntriesPath, $"{originalCode}.desktop"); var targetGamePath = Path.Combine(targetDirectory, originalCode); - Directory.CreateDirectory(targetGamePath); + if (!Directory.Exists(targetGamePath)) + Directory.CreateDirectory(targetGamePath); if (exportGames) // Copy back to reduce repeative original games repair { var realTargetGamePath = Path.Combine(Path.Combine(Path.Combine(exportDirectory, SubConsoleDirectory), string.Format("{0:D3}", menuIndex)), originalCode); @@ -1380,10 +1389,12 @@ namespace com.clusterrr.hakchi_gui throw new Exception("Can't rsync to USB drive"); } } - Directory.CreateDirectory(Path.Combine(targetGamePath, "autoplay")); + if (!Directory.Exists(Path.Combine(targetGamePath, "autoplay"))) + Directory.CreateDirectory(Path.Combine(targetGamePath, "autoplay")); if (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom) { - Directory.CreateDirectory(Path.Combine(targetGamePath, "pixelart")); + if (!Directory.Exists(Path.Combine(targetGamePath, "pixelart"))) + Directory.CreateDirectory(Path.Combine(targetGamePath, "pixelart")); } File.Copy(desktopFilePath, Path.Combine(targetGamePath, $"{originalCode}.desktop"), true); var gameSize = NesMiniApplication.DirectorySize(targetGamePath); @@ -1612,7 +1623,8 @@ namespace com.clusterrr.hakchi_gui ) { tmp = Path.Combine(Path.GetTempPath(), fileName); - Directory.CreateDirectory(tmp); + if (!Directory.Exists(tmp)) + Directory.CreateDirectory(tmp); szExtractor.ExtractArchive(tmp); fileName = Path.Combine(tmp, fileName); } @@ -1677,7 +1689,8 @@ namespace com.clusterrr.hakchi_gui listViewItem.Checked = selected.Contains("default"); games.Add(listViewItem); - Directory.CreateDirectory(NesMiniApplication.GamesDirectory); + if (!Directory.Exists(NesMiniApplication.GamesDirectory)) + Directory.CreateDirectory(NesMiniApplication.GamesDirectory); var gameDirs = Directory.GetDirectories(NesMiniApplication.GamesDirectory); int progress = 0; var maxProgress = gameDirs.Length; diff --git a/hakchi_gui.csproj b/hakchi_gui.csproj index 2b468c65..ca44aaa0 100644 --- a/hakchi_gui.csproj +++ b/hakchi_gui.csproj @@ -31,8 +31,8 @@ Alexey %27Cluster%27 Avdyukhin true index.html - 13 - 2.0.30.13 + 15 + 2.0.30.15 false true true @@ -2912,32 +2912,32 @@ False + Include + True - Include - True File False + Include + True - Include - True File False + Include + True - Include - True File -- cgit v1.2.3