Simplify access within processors

This commit is contained in:
Matt Nadareski
2024-05-21 13:14:15 -04:00
parent fad9fa5f72
commit 955fc4b8a0
9 changed files with 50 additions and 49 deletions

View File

@@ -5,6 +5,7 @@
- Seal XBC processor
- Migrate processor functionality
- Remove now-unneeded parameters classes
- Simplify access within processors
### 3.1.9a (2024-05-21)

View File

@@ -32,7 +32,7 @@ namespace MPF.Core.Processors
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
@@ -124,7 +124,7 @@ namespace MPF.Core.Processors
// Fill in the hash data
info.TracksAndWriteOffsets!.ClrMameProData = InfoTool.GenerateDatfile(datafile);
switch (this.Type)
switch (Type)
{
// TODO: Can this do GD-ROM?
case MediaType.CDROM:
@@ -164,9 +164,9 @@ namespace MPF.Core.Processors
// Deal with the layerbreak
string? layerbreak = null;
if (this.Type == MediaType.DVD)
if (Type == MediaType.DVD)
layerbreak = GetLayerbreak(sidecar) ?? string.Empty;
else if (this.Type == MediaType.BluRay)
else if (Type == MediaType.BluRay)
layerbreak = info.SizeAndChecksums!.Size > 25_025_314_816 ? "25025314816" : null;
// If we have a single-layer disc
@@ -186,7 +186,7 @@ namespace MPF.Core.Processors
break;
}
switch (this.System)
switch (System)
{
// TODO: Can we get SecuROM data?
// TODO: Can we get SS version/ranges?
@@ -314,7 +314,7 @@ namespace MPF.Core.Processors
public override List<string> GetLogFilePaths(string basePath)
{
var logFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
if (File.Exists($"{basePath}.cicm.xml"))

View File

@@ -36,8 +36,8 @@ namespace MPF.Core.Processors
/// <param name="type">MediaType value to use</param>
public BaseProcessor(RedumpSystem? system, MediaType? type)
{
this.System = system;
this.Type = type;
System = system;
Type = type;
}
#region Abstract Methods

View File

@@ -24,7 +24,7 @@ namespace MPF.Core.Processors
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.DVD: // Only added here to help users; not strictly correct
case MediaType.NintendoGameCubeGameDisc:
@@ -75,7 +75,7 @@ namespace MPF.Core.Processors
}
// Extract info based generically on MediaType
switch (this.Type)
switch (Type)
{
case MediaType.DVD: // Only added here to help users; not strictly correct
case MediaType.NintendoGameCubeGameDisc:
@@ -110,7 +110,7 @@ namespace MPF.Core.Processors
public override List<string> GetLogFilePaths(string basePath)
{
var logFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.DVD: // Only added here to help users; not strictly correct
case MediaType.NintendoGameCubeGameDisc:

View File

@@ -72,7 +72,7 @@ namespace MPF.Core.Processors
*/
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
case MediaType.GDROM:
@@ -82,7 +82,7 @@ namespace MPF.Core.Processors
missingFiles.Add($"{basePath}.img");
// Audio-only discs don't output these files
if (!this.System.IsAudio())
if (!System.IsAudio())
{
if (!File.Exists($"{basePath}.scm") && !File.Exists($"{basePath}.scmtmp"))
missingFiles.Add($"{basePath}.scm");
@@ -91,7 +91,7 @@ namespace MPF.Core.Processors
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
// GD-ROM and GD-R don't output this for the HD area
if (this.Type != MediaType.GDROM)
if (Type != MediaType.GDROM)
{
if (!File.Exists($"{basePath}.ccd"))
missingFiles.Add($"{basePath}.ccd");
@@ -121,7 +121,7 @@ namespace MPF.Core.Processors
missingFiles.Add($"{basePath}_volDesc.txt");
// Audio-only discs don't output these files
if (!this.System.IsAudio())
if (!System.IsAudio())
{
if (!File.Exists($"{basePath}.img_EdcEcc.txt") && !File.Exists($"{basePath}.img_EccEdc.txt"))
missingFiles.Add($"{basePath}.img_EdcEcc.txt");
@@ -263,14 +263,14 @@ namespace MPF.Core.Processors
VolumeLabels = volLabels;
// Extract info based generically on MediaType
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
case MediaType.GDROM: // TODO: Verify GD-ROM outputs this
info.Extras!.PVD = GetPVD($"{basePath}_mainInfo.txt") ?? "Disc has no PVD";
// Audio-only discs will fail if there are any C2 errors, so they would never get here
if (this.System.IsAudio())
if (System.IsAudio())
{
info.CommonDiscInfo!.ErrorsCount = "0";
}
@@ -314,12 +314,12 @@ namespace MPF.Core.Processors
}
// Deal with the layerbreaks
if (this.Type == MediaType.DVD)
if (Type == MediaType.DVD)
{
string layerbreak = GetLayerbreak($"{basePath}_disc.txt", System.IsXGD()) ?? string.Empty;
info.SizeAndChecksums!.Layerbreak = !string.IsNullOrEmpty(layerbreak) ? Int64.Parse(layerbreak) : default;
}
else if (this.Type == MediaType.BluRay)
else if (Type == MediaType.BluRay)
{
var di = InfoTool.GetDiscInformation($"{basePath}_PIC.bin");
info.SizeAndChecksums!.PICIdentifier = InfoTool.GetPICIdentifier(di);
@@ -341,10 +341,10 @@ namespace MPF.Core.Processors
info.Extras!.PVD = GetPVD($"{basePath}_mainInfo.txt") ?? string.Empty;
// Bluray-specific options
if (this.Type == MediaType.BluRay)
if (Type == MediaType.BluRay)
{
int trimLength = -1;
switch (this.System)
switch (System)
{
case RedumpSystem.MicrosoftXboxOne:
case RedumpSystem.MicrosoftXboxSeriesXS:
@@ -367,7 +367,7 @@ namespace MPF.Core.Processors
}
// Extract info based specifically on RedumpSystem
switch (this.System)
switch (System)
{
case RedumpSystem.AppleMacintosh:
case RedumpSystem.EnhancedCD:
@@ -505,7 +505,7 @@ namespace MPF.Core.Processors
break;
case RedumpSystem.NamcoSegaNintendoTriforce:
if (this.Type == MediaType.CDROM)
if (Type == MediaType.CDROM)
{
info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty;
@@ -541,7 +541,7 @@ namespace MPF.Core.Processors
break;
case RedumpSystem.SegaChihiro:
if (this.Type == MediaType.CDROM)
if (Type == MediaType.CDROM)
{
info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty;
@@ -561,7 +561,7 @@ namespace MPF.Core.Processors
break;
case RedumpSystem.SegaDreamcast:
if (this.Type == MediaType.CDROM)
if (Type == MediaType.CDROM)
{
info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty;
@@ -581,7 +581,7 @@ namespace MPF.Core.Processors
break;
case RedumpSystem.SegaNaomi:
if (this.Type == MediaType.CDROM)
if (Type == MediaType.CDROM)
{
info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty;
@@ -601,7 +601,7 @@ namespace MPF.Core.Processors
break;
case RedumpSystem.SegaNaomi2:
if (this.Type == MediaType.CDROM)
if (Type == MediaType.CDROM)
{
info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty;
@@ -753,7 +753,7 @@ namespace MPF.Core.Processors
public override List<string> GetDeleteableFilePaths(string basePath)
{
var deleteableFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
case MediaType.GDROM:
@@ -805,7 +805,7 @@ namespace MPF.Core.Processors
(var cmdPath, _) = GetCommandFilePathAndVersion(basePath);
var logFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
case MediaType.GDROM:

View File

@@ -24,7 +24,7 @@ namespace MPF.Core.Processors
{
var missingFiles = new List<string>();
if (this.Type != MediaType.BluRay || this.System != RedumpSystem.SonyPlayStation3)
if (Type != MediaType.BluRay || System != RedumpSystem.SonyPlayStation3)
{
missingFiles.Add("Media and system combination not supported for PS3 CFW");
}
@@ -123,10 +123,10 @@ namespace MPF.Core.Processors
var logFiles = new List<string>();
string? getKeyBasePath = GetCFWBasePath(basePath);
if (this.System != RedumpSystem.SonyPlayStation3)
if (System != RedumpSystem.SonyPlayStation3)
return logFiles;
switch (this.Type)
switch (Type)
{
case MediaType.BluRay:
if (File.Exists($"{getKeyBasePath}.getkey.log"))

View File

@@ -26,7 +26,7 @@ namespace MPF.Core.Processors
{
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
if (!File.Exists($"{basePath}.cue"))
@@ -152,7 +152,7 @@ namespace MPF.Core.Processors
if (GetVolumeLabels($"{basePath}.log", out var volLabels))
VolumeLabels = volLabels;
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
info.Extras!.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
@@ -177,14 +177,14 @@ namespace MPF.Core.Processors
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.Multisession] = cdMultiSessionInfo;
// Attempt to get the universal hash, if it's an audio disc
if (this.System.IsAudio())
if (System.IsAudio())
{
string universalHash = GetUniversalHash($"{basePath}.log") ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.UniversalHash] = universalHash;
}
// Attempt to get the non-zero data start, if it's an audio disc
if (this.System.IsAudio())
if (System.IsAudio())
{
string ringNonZeroDataStart = GetRingNonZeroDataStart($"{basePath}.log") ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.RingNonZeroDataStart] = ringNonZeroDataStart;
@@ -216,10 +216,10 @@ namespace MPF.Core.Processors
}
// Bluray-specific options
if (this.Type == MediaType.BluRay)
if (Type == MediaType.BluRay)
{
int trimLength = -1;
switch (this.System)
switch (System)
{
case RedumpSystem.MicrosoftXboxOne:
case RedumpSystem.MicrosoftXboxSeriesXS:
@@ -249,7 +249,7 @@ namespace MPF.Core.Processors
break;
}
switch (this.System)
switch (System)
{
case RedumpSystem.AppleMacintosh:
case RedumpSystem.EnhancedCD:
@@ -502,7 +502,7 @@ namespace MPF.Core.Processors
{
var logFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.CDROM:
if (File.Exists($"{basePath}.cdtext"))

View File

@@ -24,7 +24,7 @@ namespace MPF.Core.Processors
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.UMD:
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
@@ -64,7 +64,7 @@ namespace MPF.Core.Processors
VolumeLabels = volLabels;
// Extract info based generically on MediaType
switch (this.Type)
switch (Type)
{
case MediaType.UMD:
info.Extras!.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty;
@@ -124,7 +124,7 @@ namespace MPF.Core.Processors
public override List<string> GetLogFilePaths(string basePath)
{
var logFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.UMD:
if (File.Exists($"{basePath}_disc.txt"))

View File

@@ -24,7 +24,7 @@ namespace MPF.Core.Processors
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
var missingFiles = new List<string>();
switch (this.Type)
switch (Type)
{
case MediaType.DVD:
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
@@ -79,7 +79,7 @@ namespace MPF.Core.Processors
info.CommonDiscInfo!.ErrorsCount = readErrors == -1 ? "Error retrieving error count" : readErrors.ToString();
// Extract info based generically on MediaType
switch (this.Type)
switch (Type)
{
case MediaType.DVD:
@@ -105,7 +105,7 @@ namespace MPF.Core.Processors
info.SizeAndChecksums.SHA1 = sha1;
}
switch (this.System)
switch (System)
{
case RedumpSystem.MicrosoftXbox:
@@ -204,7 +204,7 @@ namespace MPF.Core.Processors
{
var logFiles = new List<string>();
string baseDir = Path.GetDirectoryName(basePath) + Path.DirectorySeparatorChar;
switch (this.Type)
switch (Type)
{
case MediaType.DVD:
string? logPath = GetLogName(baseDir);
@@ -459,7 +459,7 @@ namespace MPF.Core.Processors
bool success = long.TryParse(errorCount, out readErrors);
// Original Xbox should have 65536 read errors when dumping with XBC
if (this.System == RedumpSystem.MicrosoftXbox)
if (System == RedumpSystem.MicrosoftXbox)
{
if (readErrors == 65536)
readErrors = 0;
@@ -492,7 +492,7 @@ namespace MPF.Core.Processors
if (string.IsNullOrEmpty(log) || !File.Exists(log))
return null;
if (this.System == RedumpSystem.MicrosoftXbox)
if (System == RedumpSystem.MicrosoftXbox)
return null;
// Example: