diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index 0e3c50e9ea..fe6c2c5bc1 100644 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -122,9 +122,9 @@ namespace BizHawk.Client.DiscoHawk using var disc = Disc.LoadAutomagic(file); var path = Path.GetDirectoryName(file); var filename = Path.GetFileNameWithoutExtension(file); - static bool? PromptForOverwrite() + static bool? PromptForOverwrite(string mp3Path) => MessageBox.Show( - "Do you want to overwrite existing files? Choosing \"No\" will simply skip those. You could also \"Cancel\" the extraction entirely.", + $"Do you want to overwrite existing files? Choosing \"No\" will simply skip those. You could also \"Cancel\" the extraction entirely.\n\ncaused by file: {mp3Path}", "File to extract already exists", MessageBoxButtons.YesNoCancel) switch { diff --git a/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/AudioExtractor.cs b/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/AudioExtractor.cs index b318ea0309..f2c1d03c3c 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/AudioExtractor.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/AudioExtractor.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.DiscoHawk { public static class AudioExtractor { - public static void Extract(Disc disc, string path, string fileBase, Func getOverwritePolicy) + public static void Extract(Disc disc, string path, string fileBase, Func getOverwritePolicy) { var dsr = new DiscSectorReader(disc); @@ -36,7 +36,7 @@ namespace BizHawk.Client.DiscoHawk var mp3Path = $"{Path.Combine(path, fileBase)} - Track {track.Number:D2}.mp3"; if (File.Exists(mp3Path)) { - overwriteExisting ??= getOverwritePolicy(); + overwriteExisting ??= getOverwritePolicy(mp3Path); switch (overwriteExisting) { case true: // "Yes" -- overwrite diff --git a/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/DiscoHawkLogic.cs b/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/DiscoHawkLogic.cs index 42770ba10a..d25726b398 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/DiscoHawkLogic.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscoHawkLogic/DiscoHawkLogic.cs @@ -4,6 +4,8 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +using BizHawk.Client.DiscoHawk; + namespace BizHawk.Emulation.DiscSystem { /// @@ -267,7 +269,8 @@ namespace BizHawk.Emulation.DiscSystem var loadDiscInterface = DiscInterface.BizHawk; var compareDiscInterfaces = new List(); bool hawk = false; - + bool music = false; + bool overwrite = false; int idx = 0; while (idx < args.Length) { @@ -284,6 +287,14 @@ namespace BizHawk.Emulation.DiscSystem dirArg = args[idx++]; scanCues = true; } + else if (au is "MUSIC") + { + music = true; + } + else if (au is "OVERWRITE") + { + overwrite = true; + } else infile = a; } @@ -296,6 +307,21 @@ namespace BizHawk.Emulation.DiscSystem discInterface: loadDiscInterface); } + if (music) + { + if (infile is null) return; + using var disc = Disc.LoadAutomagic(infile); + var path = Path.GetDirectoryName(infile); + var filename = Path.GetFileNameWithoutExtension(infile); + bool? CheckOverwrite(string mp3Path) + { + if (overwrite) return true; // overwrite + Console.WriteLine($"{mp3Path} already exists. Remove existing output files, or retry with the extra argument \"OVERWRITE\"."); + return null; // cancel + } + AudioExtractor.Extract(disc, path, filename, CheckOverwrite); + } + bool verbose = true; if (scanCues)