Merge pull request #1517 from TASVideos/interp_emucommon
Use string interpolation in BizHawk.Emulation.Common and BizHawk.Emulation.DiscSystem
This commit is contained in:
commit
f4340943c0
|
@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Common
|
|||
DB.TryGetValue(hashNotype, out cgi);
|
||||
if (cgi == null)
|
||||
{
|
||||
Console.WriteLine("DB: hash " + hash + " not in game database.");
|
||||
Console.WriteLine($"DB: hash {hash} not in game database.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Error parsing database entry: " + line);
|
||||
Console.WriteLine($"Error parsing database entry: {line}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
|
||||
public NoAvailableCoreException(string message)
|
||||
: base ("System is currently NOT emulated: " + message)
|
||||
: base ($"System is currently NOT emulated: {message}")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
handle = mednadisc_LoadCD(pathToDisc);
|
||||
if (handle == IntPtr.Zero)
|
||||
throw new InvalidOperationException("Failed to load MednaDisc: " + pathToDisc);
|
||||
throw new InvalidOperationException($"Failed to load MednaDisc: {pathToDisc}");
|
||||
|
||||
//read the mednafen toc
|
||||
TOCTracks = new MednadiscTOCTrack[101];
|
||||
|
|
|
@ -466,7 +466,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
public bool GetISO9660(byte[] buffer)
|
||||
{
|
||||
//zero 24-jun-2013 - validate ISO9660
|
||||
// "CD001" + 0x01
|
||||
// "CD001\x01"
|
||||
if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01)
|
||||
{
|
||||
ISOFile.Format = ISOFile.ISOFormat.ISO9660;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
private static string[] Escape(IEnumerable<string> args)
|
||||
{
|
||||
return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray();
|
||||
return args.Select(s => s.Contains(" ") ? $"\"{s}\"" : s).ToArray();
|
||||
}
|
||||
|
||||
//note: accepts . or : in the stream stream/substream separator in the stream ID format, since that changed at some point in FFMPEG history
|
||||
|
@ -92,10 +92,10 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
{
|
||||
var runResults = Run("-i", path, "-xerror", "-f", "wav", "-ar", "44100", "-ac", "2", "-acodec", "pcm_s16le", "-y", tempfile);
|
||||
if(runResults.ExitCode != 0)
|
||||
throw new InvalidOperationException("Failure running ffmpeg for audio decode. here was its output:\r\n" + runResults.Text);
|
||||
throw new InvalidOperationException($"Failure running ffmpeg for audio decode. here was its output:\r\n{runResults.Text}");
|
||||
byte[] ret = File.ReadAllBytes(tempfile);
|
||||
if (ret.Length == 0)
|
||||
throw new InvalidOperationException("Failure running ffmpeg for audio decode. here was its output:\r\n" + runResults.Text);
|
||||
throw new InvalidOperationException($"Failure running ffmpeg for audio decode. here was its output:\r\n{runResults.Text}");
|
||||
return ret;
|
||||
}
|
||||
finally
|
||||
|
@ -163,7 +163,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
string path = FindAudio(audioPath);
|
||||
if (path == null)
|
||||
{
|
||||
throw new AudioDecoder_Exception("Could not find source audio for: " + Path.GetFileName(audioPath));
|
||||
throw new AudioDecoder_Exception($"Could not find source audio for: {Path.GetFileName(audioPath)}");
|
||||
}
|
||||
return new FFMpeg().DecodeAudio(path);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
public class DiscReferenceException : Exception
|
||||
{
|
||||
public DiscReferenceException(string fname, Exception inner)
|
||||
: base(string.Format("A disc attempted to reference a file which could not be accessed or loaded: {0}", fname), inner)
|
||||
: base($"A disc attempted to reference a file which could not be accessed or loaded: {fname}", inner)
|
||||
{
|
||||
}
|
||||
public DiscReferenceException(string fname, string extrainfo)
|
||||
: base(string.Format("A disc attempted to reference a file which could not be accessed or loaded:\n\n{0}\n\n{1}", fname, extrainfo))
|
||||
: base($"A disc attempted to reference a file which could not be accessed or loaded:\n\n{fname}\n\n{extrainfo}")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
private static string ReadTag(BinaryReader br)
|
||||
{
|
||||
return "" + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar();
|
||||
return $"{br.ReadChar()}{br.ReadChar()}{br.ReadChar()}{br.ReadChar()}";
|
||||
}
|
||||
|
||||
protected static void WriteTag(BinaryWriter bw, string tag)
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
{
|
||||
int ret;
|
||||
if(!TryGetValue(key, out ret))
|
||||
throw new CCDParseException("Malformed or unexpected CCD format: missing required [Entry] key: " + key);
|
||||
throw new CCDParseException($"Malformed or unexpected CCD format: missing required [Entry] key: {key}");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("I#{0:D2} {1}", Number, FileMSF);
|
||||
return $"I#{Number:D2} {FileMSF}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
public CompiledCueFileType Type;
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}: {1}", Type, Path.GetFileName(FullPath));
|
||||
return $"{Type}: {Path.GetFileName(FullPath)}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,11 +109,11 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
{
|
||||
var idx = Indexes.Find((i) => i.Number == 1);
|
||||
if (idx == null)
|
||||
return string.Format("T#{0:D2} NO INDEX 1", Number);
|
||||
return $"T#{Number:D2} NO INDEX 1";
|
||||
else
|
||||
{
|
||||
var indexlist = string.Join("|", Indexes);
|
||||
return string.Format("T#{0:D2} {1}:{2} ({3})", Number, BlobIndex, idx.FileMSF, indexlist);
|
||||
return $"T#{Number:D2} {BlobIndex}:{idx.FileMSF} ({indexlist})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
string choice = null;
|
||||
if (options.Count == 0)
|
||||
{
|
||||
Error(string.Format("Couldn't resolve referenced cue file: {0} ; you can commonly repair the cue file yourself, or a file might be missing", f.Path));
|
||||
Error($"Couldn't resolve referenced cue file: {f.Path} ; you can commonly repair the cue file yourself, or a file might be missing");
|
||||
//add a null entry to keep the count from being wrong later (quiets a warning)
|
||||
OUT_CompiledCueFiles.Add(null);
|
||||
return;
|
||||
|
@ -232,7 +232,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
{
|
||||
choice = options[0];
|
||||
if (options.Count > 1)
|
||||
Warn("Multiple options resolving referenced cue file; choosing: " + Path.GetFileName(choice));
|
||||
Warn($"Multiple options resolving referenced cue file; choosing: {Path.GetFileName(choice)}");
|
||||
}
|
||||
|
||||
var cfi = new CompiledCueFile();
|
||||
|
@ -275,7 +275,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
cfi.Type = CompiledCueFileType.ECM;
|
||||
if (!Disc.Blob_ECM.IsECM(choice))
|
||||
{
|
||||
Error("an ECM file was specified or detected, but it isn't a valid ECM file: " + Path.GetFileName(choice));
|
||||
Error($"an ECM file was specified or detected, but it isn't a valid ECM file: {Path.GetFileName(choice)}");
|
||||
cfi.Type = CompiledCueFileType.Unknown;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,20 +12,20 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
public static class Command
|
||||
{
|
||||
//TODO - record line number origin of command? Kind of nice but inessential
|
||||
public class CATALOG { public string Value; public override string ToString() { return string.Format("CATALOG: {0}", Value); } }
|
||||
public class CDTEXTFILE { public string Path; public override string ToString() { return string.Format("CDTEXTFILE: {0}", Path); } }
|
||||
public class FILE { public string Path; public CueFileType Type; public override string ToString() { return string.Format("FILE ({0}): {1}", Type, Path); } }
|
||||
public class FLAGS { public CueTrackFlags Flags; public override string ToString() { return string.Format("FLAGS {0}", Flags); } }
|
||||
public class INDEX { public int Number; public Timestamp Timestamp; public override string ToString() { return string.Format("INDEX {0,2} {1}", Number, Timestamp); } }
|
||||
public class ISRC { public string Value; public override string ToString() { return string.Format("ISRC: {0}", Value); } }
|
||||
public class PERFORMER { public string Value; public override string ToString() { return string.Format("PERFORMER: {0}", Value); } }
|
||||
public class POSTGAP { public Timestamp Length; public override string ToString() { return string.Format("POSTGAP: {0}", Length); } }
|
||||
public class PREGAP { public Timestamp Length; public override string ToString() { return string.Format("PREGAP: {0}", Length); } }
|
||||
public class REM { public string Value; public override string ToString() { return string.Format("REM: {0}", Value); } }
|
||||
public class COMMENT { public string Value; public override string ToString() { return string.Format("COMMENT: {0}", Value); } }
|
||||
public class SONGWRITER { public string Value; public override string ToString() { return string.Format("SONGWRITER: {0}", Value); } }
|
||||
public class TITLE { public string Value; public override string ToString() { return string.Format("TITLE: {0}", Value); } }
|
||||
public class TRACK { public int Number; public CueTrackType Type; public override string ToString() { return string.Format("TRACK {0,2} ({1})", Number, Type); } }
|
||||
public class CATALOG { public string Value; public override string ToString() { return $"CATALOG: {Value}"; } }
|
||||
public class CDTEXTFILE { public string Path; public override string ToString() { return $"CDTEXTFILE: {Path}"; } }
|
||||
public class FILE { public string Path; public CueFileType Type; public override string ToString() { return $"FILE ({Type}): {Path}"; } }
|
||||
public class FLAGS { public CueTrackFlags Flags; public override string ToString() { return $"FLAGS {Flags}"; } }
|
||||
public class INDEX { public int Number; public Timestamp Timestamp; public override string ToString() { return $"INDEX {Number,2} {Timestamp}"; } }
|
||||
public class ISRC { public string Value; public override string ToString() { return $"ISRC: {Value}"; } }
|
||||
public class PERFORMER { public string Value; public override string ToString() { return $"PERFORMER: {Value}"; } }
|
||||
public class POSTGAP { public Timestamp Length; public override string ToString() { return $"POSTGAP: {Length}"; } }
|
||||
public class PREGAP { public Timestamp Length; public override string ToString() { return $"PREGAP: {Length}"; } }
|
||||
public class REM { public string Value; public override string ToString() { return $"REM: {Value}"; } }
|
||||
public class COMMENT { public string Value; public override string ToString() { return $"COMMENT: {Value}"; } }
|
||||
public class SONGWRITER { public string Value; public override string ToString() { return $"SONGWRITER: {Value}"; } }
|
||||
public class TITLE { public string Value; public override string ToString() { return $"TITLE: {Value}"; } }
|
||||
public class TRACK { public int Number; public CueTrackType Type; public override string ToString() { return $"TRACK {Number,2} ({Type})"; } }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
|
||||
default:
|
||||
case CueTrackType.Mode2_2336:
|
||||
throw new InvalidOperationException("Not supported: " + cct.TrackType);
|
||||
throw new InvalidOperationException($"Not supported: {cct.TrackType}");
|
||||
}
|
||||
|
||||
ss.Blob = curr_blobInfo.Blob;
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
else switch (key)
|
||||
{
|
||||
default:
|
||||
job.Warn("Unknown command: " + key);
|
||||
job.Warn($"Unknown command: {key}");
|
||||
break;
|
||||
|
||||
case "CATALOG":
|
||||
|
@ -204,7 +204,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
switch (strType)
|
||||
{
|
||||
default:
|
||||
job.Error("Unknown FILE type: " + strType);
|
||||
job.Error($"Unknown FILE type: {strType}");
|
||||
ft = CueFileType.Unspecified;
|
||||
break;
|
||||
case "BINARY": ft = CueFileType.BINARY; break;
|
||||
|
@ -229,7 +229,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
{
|
||||
case "DATA":
|
||||
default:
|
||||
job.Warn("Unknown FLAG: " + flag);
|
||||
job.Warn($"Unknown FLAG: {flag}");
|
||||
break;
|
||||
case "DCP": cmd.Flags |= CueTrackFlags.DCP; break;
|
||||
case "4CH": cmd.Flags |= CueTrackFlags._4CH; break;
|
||||
|
@ -253,7 +253,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
int indexnum;
|
||||
if (!int.TryParse(strindexnum, out indexnum) || indexnum < 0 || indexnum > 99)
|
||||
{
|
||||
job.Error("Invalid INDEX number: " + strindexnum);
|
||||
job.Error($"Invalid INDEX number: {strindexnum}");
|
||||
break;
|
||||
}
|
||||
string str_timestamp = clp.ReadToken();
|
||||
|
@ -267,7 +267,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
if (!ts.Valid)
|
||||
{
|
||||
if (IN_Strict)
|
||||
job.Error("Invalid INDEX timestamp: " + str_timestamp);
|
||||
job.Error($"Invalid INDEX timestamp: {str_timestamp}");
|
||||
break;
|
||||
}
|
||||
OUT_CueFile.Commands.Add(new CUE_File.Command.INDEX() { Number = indexnum, Timestamp = ts });
|
||||
|
@ -283,7 +283,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
{
|
||||
var isrc = clp.ReadToken();
|
||||
if (isrc.Length != 12)
|
||||
job.Warn("Invalid ISRC code ignored: " + isrc);
|
||||
job.Warn($"Invalid ISRC code ignored: {isrc}");
|
||||
else
|
||||
{
|
||||
OUT_CueFile.Commands.Add(OUT_CueFile.GlobalDiscInfo.ISRC = new CUE_File.Command.ISRC() { Value = isrc });
|
||||
|
@ -301,7 +301,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
var str_msf = clp.ReadToken();
|
||||
var msf = new Timestamp(str_msf);
|
||||
if (!msf.Valid)
|
||||
job.Error("Ignoring {0} with invalid length MSF: " + str_msf, key);
|
||||
job.Error($"Ignoring {{0}} with invalid length MSF: {str_msf}", key);
|
||||
else
|
||||
{
|
||||
if (key == "POSTGAP")
|
||||
|
@ -335,7 +335,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
int tracknum;
|
||||
if (!int.TryParse(str_tracknum, out tracknum) || tracknum < 1 || tracknum > 99)
|
||||
{
|
||||
job.Error("Invalid TRACK number: " + str_tracknum);
|
||||
job.Error($"Invalid TRACK number: {str_tracknum}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
switch (str_trackType.ToUpperInvariant())
|
||||
{
|
||||
default:
|
||||
job.Error("Unknown TRACK type: " + str_trackType);
|
||||
job.Error($"Unknown TRACK type: {str_trackType}");
|
||||
tt = CueTrackType.Unknown;
|
||||
break;
|
||||
case "AUDIO": tt = CueTrackType.Audio; break;
|
||||
|
@ -372,7 +372,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
//add a comment
|
||||
OUT_CueFile.Commands.Add(new CUE_File.Command.COMMENT() { Value = remainder });
|
||||
}
|
||||
else job.Warn("Unknown text at end of line after processing command: " + key);
|
||||
else job.Warn($"Unknown text at end of line after processing command: {key}");
|
||||
}
|
||||
|
||||
} //end cue parsing loop
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
|
||||
case CueTrackType.Mode2_2336:
|
||||
default:
|
||||
throw new InvalidOperationException("Not supported: " + TrackType);
|
||||
throw new InvalidOperationException($"Not supported: {TrackType}");
|
||||
}
|
||||
|
||||
//audio has no sector header but the others do
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
if (aFile.Header.Version[0] > 1)
|
||||
{
|
||||
throw new MDSParseException("MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: " + aFile.Header.Version[0] + "." + aFile.Header.Version[1]);
|
||||
throw new MDSParseException($"MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: {aFile.Header.Version[0]}.{aFile.Header.Version[1]}");
|
||||
}
|
||||
|
||||
// parse sessions
|
||||
|
@ -477,11 +477,11 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
if (f.FilenameOffset == 0 ||
|
||||
string.Compare(fileName, "*.mdf", StringComparison.InvariantCultureIgnoreCase) == 0)
|
||||
{
|
||||
fileName = dir + @"\" + Path.GetFileNameWithoutExtension(aFile.MDSPath) + ".mdf";
|
||||
fileName = $@"{dir}\{Path.GetFileNameWithoutExtension(aFile.MDSPath)}.mdf";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = dir + @"\" + fileName;
|
||||
fileName = $@"{dir}\{fileName}";
|
||||
}
|
||||
|
||||
track.ImageFileNamePaths.Add(fileName);
|
||||
|
@ -621,7 +621,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
foreach (var file in track.ImageFileNamePaths.Distinct())
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
throw new MDSParseException("Malformed MDS format: nonexistent image file: " + file);
|
||||
throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}");
|
||||
|
||||
IBlob mdfBlob = null;
|
||||
long mdfLen = -1;
|
||||
|
@ -848,7 +848,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
//userSector = 2048;
|
||||
break;
|
||||
|
||||
//throw new Exception("Not supported: Sector Size " + track.SectorSize);
|
||||
//throw new Exception($"Not supported: Sector Size {track.SectorSize}");
|
||||
}
|
||||
|
||||
// configure blob
|
||||
|
|
|
@ -116,11 +116,10 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
{
|
||||
//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);
|
||||
cue_content = $@"
|
||||
FILE ""{filebase}"" BINARY
|
||||
TRACK 01 MODE1/2048
|
||||
INDEX 01 00:00:00";
|
||||
infile = Path.ChangeExtension(infile, ".cue");
|
||||
goto RERUN;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
get
|
||||
{
|
||||
if (!Valid) return "--:--:--";
|
||||
return string.Format("{0}{1:D2}:{2:D2}:{3:D2}", Negative ? '-' : '+', MIN, SEC, FRAC);
|
||||
return $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue