private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) { List <string> files = validateDrop(e.Data); if (files.Count == 0) { return; } try { this.Cursor = Cursors.WaitCursor; foreach (var file in files) { var disc = Disc.LoadAutomagic(file); string baseName = Path.GetFileNameWithoutExtension(file); baseName += "_hawked"; string outfile = Path.Combine(Path.GetDirectoryName(file), baseName) + ".ccd"; CCD_Format.Dump(disc, outfile); } this.Cursor = Cursors.Default; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "oops! error"); throw; } }
private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) { List <string> files = ValidateDrop(e.Data); if (files.Count == 0) { return; } try { Cursor = Cursors.WaitCursor; foreach (var file in files) { var job = new DiscMountJob { IN_FromPath = file }; job.Run(); var disc = job.OUT_Disc; if (job.OUT_ErrorLevel) { 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; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error loading disc"); throw; } }
void RunBizHawk() { string infile = IN_FromPath; string cue_content = null; var cfr = new CueFileResolver(); RERUN: var ext = Path.GetExtension(infile).ToLowerInvariant(); if (ext == ".iso") { //make a fake cue file to represent this iso file and rerun it as a cue string filebase = Path.GetFileName(infile); cue_content = string.Format(@" FILE ""{0}"" BINARY TRACK 01 MODE1/2048 INDEX 01 00:00:00" , filebase); infile = Path.ChangeExtension(infile, ".cue"); goto RERUN; } if (ext == ".cue") { //TODO - major renovation of error handling needed //TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors. //perhaps the CUE_Format2 (once renamed to something like Context) can handle that var cuePath = IN_FromPath; var cueContext = new CUE_Context(); cueContext.DiscMountPolicy = IN_DiscMountPolicy; cueContext.Resolver = cfr; if (!cfr.IsHardcodedResolve) { cfr.SetBaseDirectory(Path.GetDirectoryName(infile)); } //parse the cue file var parseJob = new ParseCueJob(); if (cue_content == null) { cue_content = File.ReadAllText(cuePath); } parseJob.IN_CueString = cue_content; bool okParse = true; try { parseJob.Run(parseJob); } catch (DiscJobAbortException) { okParse = false; parseJob.FinishLog(); } if (!string.IsNullOrEmpty(parseJob.OUT_Log)) { Console.WriteLine(parseJob.OUT_Log); } ConcatenateJobLog(parseJob); if (!okParse) { goto DONE; } //compile the cue file: //includes this work: resolve required bin files and find out what it's gonna take to load the cue var compileJob = new CompileCueJob(); compileJob.IN_CueContext = cueContext; compileJob.IN_CueFile = parseJob.OUT_CueFile; bool okCompile = true; try { compileJob.Run(); } catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); } if (!string.IsNullOrEmpty(compileJob.OUT_Log)) { Console.WriteLine(compileJob.OUT_Log); } ConcatenateJobLog(compileJob); if (!okCompile || compileJob.OUT_ErrorLevel) { goto DONE; } //check slow loading threshold if (compileJob.OUT_LoadTime > IN_SlowLoadAbortThreshold) { Warn("Loading terminated due to slow load threshold"); OUT_SlowLoadAborted = true; goto DONE; } //actually load it all up var loadJob = new LoadCueJob(); loadJob.IN_CompileJob = compileJob; loadJob.Run(); //TODO - need better handling of log output if (!string.IsNullOrEmpty(loadJob.OUT_Log)) { Console.WriteLine(loadJob.OUT_Log); } ConcatenateJobLog(loadJob); OUT_Disc = loadJob.OUT_Disc; //OUT_Disc.DiscMountPolicy = IN_DiscMountPolicy; //NOT SURE WE NEED THIS (only makes sense for cue probably) } else if (ext == ".ccd") { CCD_Format ccdLoader = new CCD_Format(); OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy); } DONE: //setup the lowest level synth provider if (OUT_Disc != null) { var sssp = new ArraySectorSynthProvider() { Sectors = OUT_Disc._Sectors, FirstLBA = -150 }; OUT_Disc.SynthProvider = sssp; } }
public static Disc FromCCDPath(string ccdPath) { CCD_Format ccdLoader = new CCD_Format(); return ccdLoader.LoadCCDToDisc(ccdPath); }
void RunBizHawk() { string infile = IN_FromPath; string cue_content = null; var cfr = new CueFileResolver(); RERUN: var ext = Path.GetExtension(infile).ToLowerInvariant(); if (ext == ".iso") { //make a fake cue file to represent this iso file and rerun it as a cue string filebase = Path.GetFileName(infile); cue_content = string.Format(@" FILE ""{0}"" BINARY TRACK 01 MODE1/2048 INDEX 01 00:00:00", filebase); infile = Path.ChangeExtension(infile, ".cue"); goto RERUN; } if (ext == ".cue") { //TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors. //perhaps the CUE_Format2 (once renamed to something like Context) can handle that var cuePath = IN_FromPath; var cueContext = new CUE_Context(); cueContext.DiscMountPolicy = IN_DiscMountPolicy; cueContext.Resolver = cfr; if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile)); //parse the cue file var parseJob = new ParseCueJob(); if (cue_content == null) cue_content = File.ReadAllText(cuePath); parseJob.IN_CueString = cue_content; parseJob.Run(parseJob); //TODO - need better handling of log output if (!string.IsNullOrEmpty(parseJob.OUT_Log)) Console.WriteLine(parseJob.OUT_Log); ConcatenateJobLog(parseJob); //compile the cue file: //includes this work: resolve required bin files and find out what it's gonna take to load the cue var compileJob = new CompileCueJob(); compileJob.IN_CueContext = cueContext; compileJob.IN_CueFile = parseJob.OUT_CueFile; compileJob.Run(); //TODO - need better handling of log output if (!string.IsNullOrEmpty(compileJob.OUT_Log)) Console.WriteLine(compileJob.OUT_Log); ConcatenateJobLog(compileJob); //check slow loading threshold if (compileJob.OUT_LoadTime >= IN_SlowLoadAbortThreshold) { Warn("Loading terminated due to slow load threshold"); OUT_SlowLoadAborted = true; goto DONE; } //actually load it all up var loadJob = new LoadCueJob(); loadJob.IN_CompileJob = compileJob; loadJob.Run(); //TODO - need better handling of log output if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log); ConcatenateJobLog(loadJob); OUT_Disc = loadJob.OUT_Disc; //OUT_Disc.DiscMountPolicy = IN_DiscMountPolicy; //NOT SURE WE NEED THIS (only makes sense for cue probably) //apply SBI if it exists (TODO - for formats other than cue?) var sbiPath = Path.ChangeExtension(IN_FromPath, ".sbi"); if (File.Exists(sbiPath) && SBI.SBIFormat.QuickCheckISSBI(sbiPath)) { var loadSbiJob = new SBI.LoadSBIJob() { IN_Path = sbiPath }; loadSbiJob.Run(); var applySbiJob = new ApplySBIJob(); applySbiJob.Run(OUT_Disc, loadSbiJob.OUT_Data, IN_DiscMountPolicy.SBI_As_Mednafen); } } else if (ext == ".ccd") { CCD_Format ccdLoader = new CCD_Format(); OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy); } DONE: ; }
void RunBizHawk() { string infile = IN_FromPath; string cue_content = null; var cfr = new CueFileResolver(); RERUN: var ext = Path.GetExtension(infile).ToLowerInvariant(); if (ext == ".iso") { //make a fake cue file to represent this iso file and rerun it as a cue string filebase = Path.GetFileName(infile); cue_content = string.Format(@" FILE ""{0}"" BINARY TRACK 01 MODE1/2048 INDEX 01 00:00:00", filebase); infile = Path.ChangeExtension(infile, ".cue"); goto RERUN; } if (ext == ".cue") { //TODO - major renovation of error handling needed //TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors. //perhaps the CUE_Format2 (once renamed to something like Context) can handle that var cuePath = IN_FromPath; var cueContext = new CUE_Context(); cueContext.DiscMountPolicy = IN_DiscMountPolicy; cueContext.Resolver = cfr; if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile)); //parse the cue file var parseJob = new ParseCueJob(); if (cue_content == null) cue_content = File.ReadAllText(cuePath); parseJob.IN_CueString = cue_content; bool okParse = true; try { parseJob.Run(parseJob); } catch (DiscJobAbortException) { okParse = false; parseJob.FinishLog(); } if (!string.IsNullOrEmpty(parseJob.OUT_Log)) Console.WriteLine(parseJob.OUT_Log); ConcatenateJobLog(parseJob); if (!okParse) goto DONE; //compile the cue file: //includes this work: resolve required bin files and find out what it's gonna take to load the cue var compileJob = new CompileCueJob(); compileJob.IN_CueContext = cueContext; compileJob.IN_CueFile = parseJob.OUT_CueFile; bool okCompile = true; try { compileJob.Run(); } catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); } if (!string.IsNullOrEmpty(compileJob.OUT_Log)) Console.WriteLine(compileJob.OUT_Log); ConcatenateJobLog(compileJob); if (!okCompile || compileJob.OUT_ErrorLevel) goto DONE; //check slow loading threshold if (compileJob.OUT_LoadTime > IN_SlowLoadAbortThreshold) { Warn("Loading terminated due to slow load threshold"); OUT_SlowLoadAborted = true; goto DONE; } //actually load it all up var loadJob = new LoadCueJob(); loadJob.IN_CompileJob = compileJob; loadJob.Run(); //TODO - need better handling of log output if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log); ConcatenateJobLog(loadJob); OUT_Disc = loadJob.OUT_Disc; //OUT_Disc.DiscMountPolicy = IN_DiscMountPolicy; //NOT SURE WE NEED THIS (only makes sense for cue probably) } else if (ext == ".ccd") { CCD_Format ccdLoader = new CCD_Format(); OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy); } DONE: //setup the lowest level synth provider if (OUT_Disc != null) { var sssp = new ArraySectorSynthProvider() { Sectors = OUT_Disc._Sectors, FirstLBA = -150 }; OUT_Disc.SynthProvider = sssp; } }