Encapsulate "hawking" routine in DiscoHawk and use it in CLI
resolves #2947
This commit is contained in:
parent
253d532a63
commit
a514effba7
|
@ -42,19 +42,10 @@ namespace BizHawk.Client.DiscoHawk
|
||||||
Cursor = Cursors.WaitCursor;
|
Cursor = Cursors.WaitCursor;
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var job = new DiscMountJob(fromPath: file);
|
var success = DiscoHawkLogic.HawkAndWriteFile(
|
||||||
job.Run();
|
inputPath: file,
|
||||||
var disc = job.OUT_Disc;
|
errorCallback: err => MessageBox.Show(err, "Error loading disc"));
|
||||||
if (job.OUT_ErrorLevel)
|
if (!success) break;
|
||||||
{
|
|
||||||
MessageBox.Show(job.OUT_Log, "Error loading disc");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
string baseName = Path.GetFileNameWithoutExtension(file);
|
|
||||||
baseName += "_hawked";
|
|
||||||
string outfile = $"{Path.Combine(Path.GetDirectoryName(file), baseName)}.ccd";
|
|
||||||
CCD_Format.Dump(disc, outfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor = Cursors.Default;
|
Cursor = Cursors.Default;
|
||||||
|
|
|
@ -243,6 +243,22 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HawkAndWriteFile(string inputPath, Action<string> errorCallback, DiscInterface discInterface = DiscInterface.BizHawk)
|
||||||
|
{
|
||||||
|
DiscMountJob job = new(inputPath, discInterface);
|
||||||
|
job.Run();
|
||||||
|
var disc = job.OUT_Disc;
|
||||||
|
if (job.OUT_ErrorLevel)
|
||||||
|
{
|
||||||
|
errorCallback(job.OUT_Log);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var baseName = Path.GetFileNameWithoutExtension(inputPath);
|
||||||
|
var outfile = Path.Combine(Path.GetDirectoryName(inputPath), $"{baseName}_hawked.ccd");
|
||||||
|
CCD_Format.Dump(disc, outfile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void RunWithArgs(string[] args, Action<string> showComparisonResultsCallback)
|
public static void RunWithArgs(string[] args, Action<string> showComparisonResultsCallback)
|
||||||
{
|
{
|
||||||
bool scanCues = false;
|
bool scanCues = false;
|
||||||
|
@ -273,14 +289,11 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
|
|
||||||
if (hawk)
|
if (hawk)
|
||||||
{
|
{
|
||||||
if (infile == null)
|
if (infile == null) return;
|
||||||
{
|
HawkAndWriteFile(
|
||||||
return;
|
inputPath: infile,
|
||||||
}
|
errorCallback: err => Console.WriteLine($"failed to convert {infile}:\n{err}"),
|
||||||
|
discInterface: loadDiscInterface);
|
||||||
// TODO - write it out
|
|
||||||
var dmj = new DiscMountJob(fromPath: infile, discInterface: loadDiscInterface);
|
|
||||||
dmj.Run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verbose = true;
|
bool verbose = true;
|
||||||
|
|
Loading…
Reference in New Issue