Compare commits

..

20 Commits
2.7.1 ... 2.7.2

Author SHA1 Message Date
Matt Nadareski
3b3c5f823d Bump version 2023-10-17 20:53:07 -04:00
Matt Nadareski
09fc313492 Support Redumper 231 outputs 2023-10-17 20:51:48 -04:00
Matt Nadareski
316d0f6e54 Clean up issue templates 2023-10-16 00:44:57 -04:00
Matt Nadareski
a0033238bd Get SecuROM data from Redumper (fixes #583) 2023-10-16 00:38:56 -04:00
Matt Nadareski
5b1c6a7f46 Update changlog 2023-10-15 21:51:51 -04:00
fuzzball
8c0dff6552 Correct the condition (#582) 2023-10-15 18:51:23 -07:00
Matt Nadareski
43b230c84a Update Redumper to build 230 2023-10-15 21:42:45 -04:00
Matt Nadareski
f1b657011d Enable parameters checkbox by default (fixes #580) 2023-10-15 15:33:18 -04:00
Matt Nadareski
e4d8ac8e1c Fix Redumper retry count not showing 2023-10-14 23:04:05 -04:00
Matt Nadareski
08f44173dd Update changelog 2023-10-13 10:56:10 -04:00
Deterous
54765c71fd Remove code for getting UH from DIC logs (#577) 2023-10-13 07:55:52 -07:00
Matt Nadareski
01f8b49214 Update changelog 2023-10-13 10:54:57 -04:00
Deterous
e8b0b3efaa Improve check for which program supports which media (#578)
* Move ProgramSupportsMedia to MPF.Core.Utilities.Tools

* Implement ProgramSupportsMedia slightly less naively

* ProgramSupportsMedia only considers MPF-supported types
2023-10-13 07:54:10 -07:00
Matt Nadareski
f637938858 Update changelog 2023-10-12 15:47:13 -04:00
Deterous
ae326c1d2f Disable dumping button when Redumper selected with unsupported media type (#576)
* Disable dumping button when HDDVD + Redumper selected

* Exclude Bluray+Redumper as well

* Move program-supports-mediatype logic to helper function

* Fix for net48

* Fix for net48

* Undo fixes for net48
2023-10-12 12:46:44 -07:00
Matt Nadareski
a4a1e6bf0a Suppress some unnecessary messages 2023-10-12 01:27:54 -04:00
Matt Nadareski
ecee44966e Gate some switch expressions 2023-10-12 01:19:47 -04:00
Matt Nadareski
83437977ba Update changelog 2023-10-11 23:56:00 -04:00
Matt Nadareski
8fcac1d425 Cleanup and gated code 2023-10-11 23:55:50 -04:00
Matt Nadareski
705b5f1049 Fix options loading for Check 2023-10-11 16:37:10 -04:00
22 changed files with 1558 additions and 561 deletions

View File

@@ -10,7 +10,6 @@ assignees: mnadareski
**Before You Submit**
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the feature already exists.
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
- .NET 6.0 has known limitations, so make sure that what you're asking for isn't already in another build.
- Check [previous issues](https://github.com/SabreTools/MPF/issues) to see if any of those are related to what you're about to ask for.
If none of those apply, then continue...

View File

@@ -10,7 +10,6 @@ assignees: mnadareski
**Before You Submit**
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the feature already exists.
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
- .NET 6.0 has known limitations, so make sure that what you're giving information on isn't already in another build.
- Check [previous issues](https://github.com/SabreTools/MPF/issues) to see if any of those are related to what you're about to ask for.
If none of those apply, then continue...

View File

@@ -10,7 +10,6 @@ assignees: mnadareski
**Before You Submit**
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the issue has already been addressed.
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
- .NET 6.0 has known issues, please try using another build to reproduce the error
- Check multiple discs to help narrow down the issue
- Check the Options to see if changing any of those affects your issue.
@@ -27,6 +26,7 @@ What runtime version are you using?
- [ ] .NET Framework 4.8 running on (Operating System)
- [ ] .NET 6.0 running on (Operating System)
- [ ] .NET 7.0 running on (Operating System)
**Describe the issue**
A clear and concise description of what the bug is.

View File

@@ -1,3 +1,20 @@
### 2.7.2 (2023-10-17)
- Fix options loading for Check
- Cleanup and gated code
- Gate some switch expressions
- Suppress some unnecessary messages
- Disable dumping button when Redumper selected with unsupported media type (Deterous)
- Improve check for which program supports which media (Deterous)
- Remove code for getting Universal Hash from DIC logs (Deterous)
- Fix Redumper retry count not showing
- Enable parameters checkbox by default
- Update Redumper to build 230
- Fix GetPVD in dic (fuzz6001)
- Get SecuROM data from Redumper
- Clean up issue templates
- Support Redumper 231 outputs
### 2.7.1 (2023-10-11)
- Add pull-all flag for Check

View File

@@ -8,7 +8,7 @@
<Description>Validator for various dumping programs</Description>
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
<Copyright>Copyright (c)2019-2023</Copyright>
<VersionPrefix>2.7.1</VersionPrefix>
<VersionPrefix>2.7.2</VersionPrefix>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">

View File

@@ -8,14 +8,22 @@ namespace MPF.Core.Data
{
public class IniFile : IDictionary<string, string>
{
#if NET48
private Dictionary<string, string> _keyValuePairs = new Dictionary<string, string>();
#else
private Dictionary<string, string> _keyValuePairs = new();
#endif
public string this[string key]
{
get
{
#if NET48
if (_keyValuePairs == null)
_keyValuePairs = new Dictionary<string, string>();
#else
_keyValuePairs ??= new Dictionary<string, string>();
#endif
key = key.ToLowerInvariant();
if (_keyValuePairs.ContainsKey(key))
@@ -25,8 +33,12 @@ namespace MPF.Core.Data
}
set
{
#if NET48
if (_keyValuePairs == null)
_keyValuePairs = new Dictionary<string, string>();
#else
_keyValuePairs ??= new Dictionary<string, string>();
#endif
key = key.ToLowerInvariant();
_keyValuePairs[key] = value;
@@ -99,7 +111,7 @@ namespace MPF.Core.Data
// Keys are case-insensitive by default
try
{
using (StreamReader sr = new StreamReader(stream))
using (var sr = new StreamReader(stream))
{
string section = string.Empty;
while (!sr.EndOfStream)
@@ -125,7 +137,11 @@ namespace MPF.Core.Data
}
// Valid INI lines are in the format key=value
#if NET48
else if (line.Contains("="))
#else
else if (line.Contains('='))
#endif
{
// Split the line by '=' for key-value pairs
string[] data = line.Split('=');
@@ -185,7 +201,7 @@ namespace MPF.Core.Data
try
{
using (StreamWriter sw = new StreamWriter(stream))
using (var sw = new StreamWriter(stream))
{
// Order the dictionary by keys to link sections together
var orderedKeyValuePairs = _keyValuePairs.OrderBy(kvp => kvp.Key);

View File

@@ -65,7 +65,7 @@ namespace MPF.Core
public BaseParameters? Parameters { get; private set; }
#endif
#endregion
#endregion
#region Event Handlers
@@ -130,16 +130,16 @@ namespace MPF.Core
#endif
{
// Set options object
this.Options = options;
Options = options;
// Output paths
this.OutputPath = InfoTool.NormalizeOutputPaths(outputPath, true);
OutputPath = InfoTool.NormalizeOutputPaths(outputPath, true);
// UI information
this.Drive = drive;
this.System = system ?? options.DefaultSystem;
this.Type = type ?? MediaType.NONE;
this.InternalProgram = internalProgram ?? options.InternalProgram;
Drive = drive;
System = system ?? options.DefaultSystem;
Type = type ?? MediaType.NONE;
InternalProgram = internalProgram ?? options.InternalProgram;
// Dumping program
SetParameters(parameters);
@@ -153,13 +153,13 @@ namespace MPF.Core
public void AdjustPathsForDiscImageCreator()
{
// Only DiscImageCreator has issues with paths
if (this.Parameters?.InternalProgram != InternalProgram.DiscImageCreator)
if (Parameters?.InternalProgram != InternalProgram.DiscImageCreator)
return;
try
{
// Normalize the output path
string outputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true);
string outputPath = InfoTool.NormalizeOutputPaths(OutputPath, true);
// Replace all instances in the output directory
var outputDirectory = Path.GetDirectoryName(outputPath);
@@ -176,20 +176,20 @@ namespace MPF.Core
if (string.IsNullOrWhiteSpace(outputDirectory))
{
if (string.IsNullOrWhiteSpace(outputExtension))
this.OutputPath = outputFilename;
OutputPath = outputFilename;
else
this.OutputPath = $"{outputFilename}.{outputExtension}";
OutputPath = $"{outputFilename}.{outputExtension}";
}
else
{
if (string.IsNullOrWhiteSpace(outputExtension))
this.OutputPath = Path.Combine(outputDirectory, outputFilename);
OutputPath = Path.Combine(outputDirectory, outputFilename);
else
this.OutputPath = Path.Combine(outputDirectory, $"{outputFilename}.{outputExtension}");
OutputPath = Path.Combine(outputDirectory, $"{outputFilename}.{outputExtension}");
}
// Assign the path to the filename as well for dumping
((Modules.DiscImageCreator.Parameters)this.Parameters).Filename = this.OutputPath;
((Modules.DiscImageCreator.Parameters)Parameters).Filename = OutputPath;
}
catch { }
}
@@ -204,45 +204,63 @@ namespace MPF.Core
public void SetParameters(string? parameters)
#endif
{
switch (this.InternalProgram)
#if NET48
switch (InternalProgram)
{
// Dumping support
case InternalProgram.Aaru:
this.Parameters = new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath };
Parameters = new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath };
break;
case InternalProgram.DiscImageCreator:
this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
break;
case InternalProgram.Redumper:
this.Parameters = new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath };
Parameters = new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath };
break;
// Verification support only
case InternalProgram.CleanRip:
this.Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null };
Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null };
break;
case InternalProgram.DCDumper:
this.Parameters = null; // TODO: Create correct parameter type when supported
Parameters = null; // TODO: Create correct parameter type when supported
break;
case InternalProgram.UmdImageCreator:
this.Parameters = new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null };
Parameters = new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null };
break;
// This should never happen, but it needs a fallback
default:
this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
break;
}
#else
Parameters = InternalProgram switch
{
// Dumping support
InternalProgram.Aaru => new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath },
InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath },
InternalProgram.Redumper => new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath },
// Verification support only
InternalProgram.CleanRip => new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null },
InternalProgram.DCDumper => null, // TODO: Create correct parameter type when supported
InternalProgram.UmdImageCreator => new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null },
// This should never happen, but it needs a fallback
_ => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath },
};
#endif
// Set system and type
if (this.Parameters != null)
if (Parameters != null)
{
this.Parameters.System = this.System;
this.Parameters.Type = this.Type;
Parameters.System = System;
Parameters.Type = Type;
}
}
@@ -265,25 +283,37 @@ namespace MPF.Core
return null;
// Set the proper parameters
switch (this.InternalProgram)
#if NET48
switch (InternalProgram)
{
case InternalProgram.Aaru:
Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options);
break;
case InternalProgram.DiscImageCreator:
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options);
break;
case InternalProgram.Redumper:
Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options);
break;
// This should never happen, but it needs a fallback
default:
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options);
break;
}
#else
Parameters = InternalProgram switch
{
InternalProgram.Aaru => new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options),
InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options),
InternalProgram.Redumper => new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options),
// This should never happen, but it needs a fallback
_ => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options),
};
#endif
// Generate and return the param string
return Parameters.GenerateParameters();
@@ -332,7 +362,7 @@ namespace MPF.Core
#endif
{
// If we don't have parameters
if (this.Parameters == null)
if (Parameters == null)
return Result.Failure("Error! Current configuration is not supported!");
// Check that we have the basics for dumping
@@ -349,19 +379,14 @@ namespace MPF.Core
}
// Execute internal tool
progress?.Report(Result.Success($"Executing {this.InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}"));
progress?.Report(Result.Success($"Executing {InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}"));
var directoryName = Path.GetDirectoryName(this.OutputPath);
var directoryName = Path.GetDirectoryName(OutputPath);
if (!string.IsNullOrWhiteSpace(directoryName))
Directory.CreateDirectory(directoryName);
await Task.Run(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow));
progress?.Report(Result.Success($"{this.InternalProgram} has finished!"));
// Execute additional tools
progress?.Report(Result.Success("Running any additional tools... see log for output!"));
result = await Task.Run(() => ExecuteAdditionalTools());
progress?.Report(result);
progress?.Report(Result.Success($"{InternalProgram} has finished!"));
// Remove event handler if needed
if (!Options.ToolsInSeparateWindow)
@@ -397,11 +422,11 @@ namespace MPF.Core
resultProgress?.Report(Result.Success("Gathering submission information... please wait!"));
// Get the output directory and filename separately
var outputDirectory = Path.GetDirectoryName(this.OutputPath);
var outputFilename = Path.GetFileName(this.OutputPath);
var outputDirectory = Path.GetDirectoryName(OutputPath);
var outputFilename = Path.GetFileName(OutputPath);
// Check to make sure that the output had all the correct files
(bool foundFiles, List<string> missingFiles) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, this.Parameters, false);
(bool foundFiles, List<string> missingFiles) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, Parameters, false);
if (!foundFiles)
{
resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}"));
@@ -411,12 +436,12 @@ namespace MPF.Core
// Extract the information from the output files
resultProgress?.Report(Result.Success("Extracting output information from output files..."));
var submissionInfo = await InfoTool.ExtractOutputInformation(
this.OutputPath,
this.Drive,
this.System,
this.Type,
this.Options,
this.Parameters,
OutputPath,
Drive,
System,
Type,
Options,
Parameters,
resultProgress,
protectionProgress);
resultProgress?.Report(Result.Success("Extracting information complete!"));
@@ -437,7 +462,7 @@ namespace MPF.Core
}
// Reset the drive automatically if configured to
if (this.InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
if (InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
{
resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Letter}"));
await ResetDrive();
@@ -464,7 +489,7 @@ namespace MPF.Core
// Format the information for the text output
resultProgress?.Report(Result.Success("Formatting information..."));
(var formattedValues, var formatResult) = InfoTool.FormatOutputData(submissionInfo, this.Options);
(var formattedValues, var formatResult) = InfoTool.FormatOutputData(submissionInfo, Options);
if (formattedValues == null)
resultProgress?.Report(Result.Success(formatResult));
else
@@ -504,7 +529,7 @@ namespace MPF.Core
if (Options.CompressLogFiles)
{
resultProgress?.Report(Result.Success("Compressing log files..."));
(bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, outputFilename, this.Parameters);
(bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, outputFilename, Parameters);
if (compressSuccess)
resultProgress?.Report(Result.Success(compressResult));
else
@@ -535,18 +560,12 @@ namespace MPF.Core
return parametersValid && floppyValid && removableDiskValid;
}
/// <summary>
/// Run any additional tools given a DumpEnvironment
/// </summary>
/// <returns>Result instance with the outcome</returns>
private Result ExecuteAdditionalTools() => Result.Success("No external tools needed!");
/// <summary>
/// Run internal program async with an input set of parameters
/// </summary>
/// <param name="parameters"></param>
/// <returns>Standard output from commandline window</returns>
private async Task<string> ExecuteInternalProgram(BaseParameters parameters)
private static async Task<string> ExecuteInternalProgram(BaseParameters parameters)
{
Process childProcess;
string output = await Task.Run(() =>
@@ -584,20 +603,21 @@ namespace MPF.Core
/// <param name="info">Existing submission information</param>
/// <param name="seed">User-supplied submission information</param>
#if NET48
private void InjectSubmissionInformation(SubmissionInfo info, SubmissionInfo seed)
private static void InjectSubmissionInformation(SubmissionInfo info, SubmissionInfo seed)
#else
private void InjectSubmissionInformation(SubmissionInfo? info, SubmissionInfo? seed)
private static void InjectSubmissionInformation(SubmissionInfo? info, SubmissionInfo? seed)
#endif
{
// If we have any invalid info
if (info == null || seed == null)
if (seed == null)
return;
// Otherwise, inject information as necessary
if (seed.CommonDiscInfo != null)
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
// Ensure that required sections exist
info = InfoTool.EnsureAllSections(info);
// Otherwise, inject information as necessary
if (info.CommonDiscInfo != null && seed.CommonDiscInfo != null)
{
// Info that only overwrites if supplied
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Title)) info.CommonDiscInfo.Title = seed.CommonDiscInfo.Title;
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.ForeignTitleNonLatin)) info.CommonDiscInfo.ForeignTitleNonLatin = seed.CommonDiscInfo.ForeignTitleNonLatin;
@@ -607,7 +627,7 @@ namespace MPF.Core
if (seed.CommonDiscInfo.Region != null) info.CommonDiscInfo.Region = seed.CommonDiscInfo.Region;
if (seed.CommonDiscInfo.Languages != null) info.CommonDiscInfo.Languages = seed.CommonDiscInfo.Languages;
if (seed.CommonDiscInfo.LanguageSelection != null) info.CommonDiscInfo.LanguageSelection = seed.CommonDiscInfo.LanguageSelection;
if (seed.CommonDiscInfo.Serial != null) info.CommonDiscInfo.Serial = seed.CommonDiscInfo.Serial;
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Serial)) info.CommonDiscInfo.Serial = seed.CommonDiscInfo.Serial;
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Barcode)) info.CommonDiscInfo.Barcode = seed.CommonDiscInfo.Barcode;
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Comments)) info.CommonDiscInfo.Comments = seed.CommonDiscInfo.Comments;
if (seed.CommonDiscInfo.CommentsSpecialFields != null) info.CommonDiscInfo.CommentsSpecialFields = seed.CommonDiscInfo.CommentsSpecialFields;
@@ -636,19 +656,15 @@ namespace MPF.Core
info.CommonDiscInfo.Layer3ToolstampMasteringCode = seed.CommonDiscInfo.Layer3ToolstampMasteringCode;
}
if (seed.VersionAndEditions != null)
if (info.VersionAndEditions != null && seed.VersionAndEditions != null)
{
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
// Info that only overwrites if supplied
if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.Version)) info.VersionAndEditions.Version = seed.VersionAndEditions.Version;
if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.OtherEditions)) info.VersionAndEditions.OtherEditions = seed.VersionAndEditions.OtherEditions;
}
if (seed.CopyProtection != null)
if (info.CopyProtection != null && seed.CopyProtection != null)
{
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
// Info that only overwrites if supplied
if (!string.IsNullOrWhiteSpace(seed.CopyProtection.Protection)) info.CopyProtection.Protection = seed.CopyProtection.Protection;
}
@@ -661,14 +677,14 @@ namespace MPF.Core
private Result IsValidForDump()
{
// Validate that everything is good
if (this.Parameters == null || !ParametersValid())
if (Parameters == null || !ParametersValid())
return Result.Failure("Error! Current configuration is not supported!");
// Fix the output paths, just in case
this.OutputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true);
OutputPath = InfoTool.NormalizeOutputPaths(OutputPath, true);
// Validate that the output path isn't on the dumping drive
if (Drive != null && this.OutputPath[0] == Drive.Letter)
if (Drive != null && OutputPath[0] == Drive.Letter)
return Result.Failure("Error! Cannot output to same drive that is being dumped!");
// Validate that the required program exists
@@ -732,6 +748,6 @@ namespace MPF.Core
return await ExecuteInternalProgram(parameters);
}
#endregion
#endregion
}
}

View File

@@ -17,6 +17,8 @@ using SabreTools.RedumpLib.Data;
using SabreTools.RedumpLib.Web;
using Formatting = Newtonsoft.Json.Formatting;
#pragma warning disable IDE0051 // Remove unused private members
namespace MPF.Core
{
public static class InfoTool
@@ -56,6 +58,58 @@ namespace MPF.Core
}
}
/// <summary>
/// Ensure all required sections in a submission info exist
/// </summary>
/// <param name="info">SubmissionInfo object to verify</param>
#if NET48
public static SubmissionInfo EnsureAllSections(SubmissionInfo info)
{
// If there's no info, create one
if (info == null) info = new SubmissionInfo();
// Ensure all sections
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
if (info.EDC == null) info.EDC = new EDCSection();
if (info.Extras == null) info.Extras = new ExtrasSection();
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
if (info.TracksAndWriteOffsets == null) info.TracksAndWriteOffsets = new TracksAndWriteOffsetsSection();
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
// Ensure special dictionaries
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
if (info.CommonDiscInfo.ContentsSpecialFields == null) info.CommonDiscInfo.ContentsSpecialFields = new Dictionary<SiteCode?, string>();
return info;
}
#else
public static SubmissionInfo EnsureAllSections(SubmissionInfo? info)
{
// If there's no info, create one
info ??= new SubmissionInfo();
// Ensure all sections
info.CommonDiscInfo ??= new CommonDiscInfoSection();
info.VersionAndEditions ??= new VersionAndEditionsSection();
info.EDC ??= new EDCSection();
info.ParentCloneRelationship ??= new ParentCloneRelationshipSection();
info.Extras ??= new ExtrasSection();
info.CopyProtection ??= new CopyProtectionSection();
info.DumpersAndStatus ??= new DumpersAndStatusSection();
info.TracksAndWriteOffsets ??= new TracksAndWriteOffsetsSection();
info.SizeAndChecksums ??= new SizeAndChecksumsSection();
info.DumpingInfo ??= new DumpingInfoSection();
// Ensure special dictionaries
info.CommonDiscInfo.CommentsSpecialFields ??= new Dictionary<SiteCode, string>();
info.CommonDiscInfo.ContentsSpecialFields ??= new Dictionary<SiteCode, string>();
return info;
}
#endif
/// <summary>
/// Extract all of the possible information from a given input combination
/// </summary>
@@ -135,34 +189,26 @@ namespace MPF.Core
Serial = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty,
Barcode = options.AddPlaceholders ? Template.OptionalValue : string.Empty,
Contents = string.Empty,
#if NET48
ContentsSpecialFields = new Dictionary<SiteCode?, string>(),
#else
ContentsSpecialFields = new Dictionary<SiteCode, string>(),
#endif
Comments = string.Empty,
#if NET48
CommentsSpecialFields = new Dictionary<SiteCode?, string>(),
#else
CommentsSpecialFields = new Dictionary<SiteCode, string>(),
#endif
},
VersionAndEditions = new VersionAndEditionsSection()
{
Version = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty,
OtherEditions = options.AddPlaceholders ? "(VERIFY THIS) Original" : string.Empty,
},
TracksAndWriteOffsets = new TracksAndWriteOffsetsSection(),
};
// Ensure that required sections exist
info = EnsureAllSections(info);
// Get specific tool output handling
parameters?.GenerateSubmissionInfo(info, options, combinedBase, drive, options.IncludeArtifacts);
// Get a list of matching IDs for each line in the DAT
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets.ClrMameProData) && options.HasRedumpLogin)
#if NET48
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets.ClrMameProData) && options.HasRedumpLogin)
FillFromRedump(options, info, resultProgress);
#else
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets!.ClrMameProData) && options.HasRedumpLogin)
_ = await FillFromRedump(options, info, resultProgress);
#endif
@@ -172,14 +218,22 @@ namespace MPF.Core
// Add the volume label to comments, if possible or necessary
if (drive?.VolumeLabel != null && drive.GetRedumpSystemFromVolumeLabel() == null)
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.VolumeLabel] = drive.VolumeLabel;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.VolumeLabel] = drive.VolumeLabel;
#endif
// Extract info based generically on MediaType
switch (mediaType)
{
case MediaType.CDROM:
case MediaType.GDROM:
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -190,12 +244,19 @@ namespace MPF.Core
case MediaType.DVD:
case MediaType.HDDVD:
case MediaType.BluRay:
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
// If we have a single-layer disc
#if NET48
if (info.SizeAndChecksums.Layerbreak == default)
#else
if (info.SizeAndChecksums!.Layerbreak == default)
#endif
{
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -205,7 +266,11 @@ namespace MPF.Core
// If we have a dual-layer disc
else
{
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -220,23 +285,37 @@ namespace MPF.Core
break;
case MediaType.NintendoGameCubeGameDisc:
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.BCA = info.Extras.BCA ?? (options.AddPlaceholders ? Template.RequiredValue : string.Empty);
#else
info.Extras!.BCA ??= (options.AddPlaceholders ? Template.RequiredValue : string.Empty);
#endif
break;
case MediaType.NintendoWiiOpticalDisc:
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
// If we have a single-layer disc
#if NET48
if (info.SizeAndChecksums.Layerbreak == default)
#else
if (info.SizeAndChecksums!.Layerbreak == default)
#endif
{
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -246,7 +325,11 @@ namespace MPF.Core
// If we have a dual-layer disc
else
{
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -258,15 +341,22 @@ namespace MPF.Core
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
}
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.Extras!.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
info.Extras.BCA = info.Extras.BCA ?? (options.AddPlaceholders ? Template.RequiredValue : string.Empty);
break;
case MediaType.UMD:
// Both single- and dual-layer discs have two "layers" for the ring
#if NET48
info.CommonDiscInfo.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
@@ -275,10 +365,15 @@ namespace MPF.Core
info.CommonDiscInfo.Layer1MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.Layer1ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
#if NET48
info.SizeAndChecksums.CRC32 = info.SizeAndChecksums.CRC32 ?? (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
info.SizeAndChecksums.MD5 = info.SizeAndChecksums.MD5 ?? (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
info.SizeAndChecksums.SHA1 = info.SizeAndChecksums.SHA1 ?? (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
#else
info.SizeAndChecksums!.CRC32 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
info.SizeAndChecksums.MD5 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
info.SizeAndChecksums.SHA1 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
#endif
info.TracksAndWriteOffsets.ClrMameProData = null;
break;
}
@@ -287,7 +382,11 @@ namespace MPF.Core
switch (system)
{
case RedumpSystem.AcornArchimedes:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.UnitedKingdom;
#else
info.CommonDiscInfo!.Region ??= Region.UnitedKingdom;
#endif
break;
case RedumpSystem.AppleMacintosh:
@@ -300,11 +399,11 @@ namespace MPF.Core
resultProgress?.Report(Result.Success("Running copy protection scan... this might take a while!"));
var (protectionString, fullProtections) = await GetCopyProtection(drive, options, protectionProgress);
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
info.CopyProtection.Protection = protectionString;
#if NET48
info.CopyProtection.Protection = protectionString;
info.CopyProtection.FullProtections = fullProtections ?? new Dictionary<string, List<string>>();
#else
info.CopyProtection!.Protection = protectionString;
info.CopyProtection.FullProtections = fullProtections as Dictionary<string, List<string>?> ?? new Dictionary<string, List<string>?>();
#endif
resultProgress?.Report(Result.Success("Copy protection scan complete!"));
@@ -314,73 +413,139 @@ namespace MPF.Core
case RedumpSystem.AudioCD:
case RedumpSystem.DVDAudio:
case RedumpSystem.SuperAudioCD:
#if NET48
info.CommonDiscInfo.Category = info.CommonDiscInfo.Category ?? DiscCategory.Audio;
#else
info.CommonDiscInfo!.Category ??= DiscCategory.Audio;
#endif
break;
case RedumpSystem.BandaiPlaydiaQuickInteractiveSystem:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
break;
case RedumpSystem.BDVideo:
#if NET48
info.CommonDiscInfo.Category = info.CommonDiscInfo.Category ?? DiscCategory.BonusDiscs;
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
info.CopyProtection.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CommonDiscInfo!.Category ??= DiscCategory.BonusDiscs;
info.CopyProtection!.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
break;
case RedumpSystem.CommodoreAmigaCD:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.CommodoreAmigaCD32:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Europe;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region ??= Region.Europe;
#endif
break;
case RedumpSystem.CommodoreAmigaCDTV:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Europe;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region ??= Region.Europe;
#endif
break;
case RedumpSystem.DVDVideo:
#if NET48
info.CommonDiscInfo.Category = info.CommonDiscInfo.Category ?? DiscCategory.BonusDiscs;
#else
info.CommonDiscInfo!.Category ??= DiscCategory.BonusDiscs;
#endif
break;
case RedumpSystem.FujitsuFMTownsseries:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
break;
case RedumpSystem.FujitsuFMTownsMarty:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.IncredibleTechnologiesEagle:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.KonamieAmusement:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.KonamiFireBeat:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.KonamiSystemGV:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.KonamiSystem573:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.KonamiTwinkle:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.MattelHyperScan:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.MicrosoftXboxOne:
@@ -389,7 +554,11 @@ namespace MPF.Core
string xboxOneMsxcPath = Path.Combine($"{drive.Letter}:\\", "MSXC");
if (drive != null && Directory.Exists(xboxOneMsxcPath))
{
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Filename] = string.Join("\n",
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.Filename] = string.Join("\n",
#endif
Directory.GetFiles(xboxOneMsxcPath, "*", SearchOption.TopDirectoryOnly).Select(Path.GetFileName));
}
}
@@ -402,7 +571,11 @@ namespace MPF.Core
string xboxSeriesXMsxcPath = Path.Combine($"{drive.Letter}:\\", "MSXC");
if (drive != null && Directory.Exists(xboxSeriesXMsxcPath))
{
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Filename] = string.Join("\n",
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.Filename] = string.Join("\n",
#endif
Directory.GetFiles(xboxSeriesXMsxcPath, "*", SearchOption.TopDirectoryOnly).Select(Path.GetFileName));
}
}
@@ -410,59 +583,112 @@ namespace MPF.Core
break;
case RedumpSystem.NamcoSegaNintendoTriforce:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.NavisoftNaviken21:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.NECPC88series:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.NECPC98series:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.NECPCFXPCFXGA:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.SegaChihiro:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SegaDreamcast:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SegaNaomi:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SegaNaomi2:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SegaTitanVideo:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SharpX68000:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.SNKNeoGeoCD:
#if NET48
info.CommonDiscInfo.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation:
// Only check the disc if the dumping program couldn't detect
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#if NET48
if (drive != null && info.CopyProtection.AntiModchip == YesNo.NULL)
#else
if (drive != null && info.CopyProtection!.AntiModchip == YesNo.NULL)
#endif
{
resultProgress?.Report(Result.Success("Checking for anti-modchip strings... this might take a while!"));
info.CopyProtection.AntiModchip = await GetAntiModchipDetected(drive) ? YesNo.Yes : YesNo.No;
@@ -480,27 +706,45 @@ namespace MPF.Core
break;
case RedumpSystem.SonyPlayStation2:
#if NET48
info.CommonDiscInfo.LanguageSelection = new LanguageSelection?[] { LanguageSelection.BiosSettings, LanguageSelection.LanguageSelector, LanguageSelection.OptionsMenu };
#else
info.CommonDiscInfo!.LanguageSelection = new LanguageSelection?[] { LanguageSelection.BiosSettings, LanguageSelection.LanguageSelector, LanguageSelection.OptionsMenu };
#endif
break;
case RedumpSystem.SonyPlayStation3:
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#else
info.Extras!.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
#endif
info.Extras.DiscID = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
break;
case RedumpSystem.TomyKissSite:
#if NET48
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
#else
info.CommonDiscInfo!.Region ??= Region.Japan;
#endif
break;
case RedumpSystem.ZAPiTGamesGameWaveFamilyEntertainmentSystem:
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#if NET48
info.CopyProtection.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#else
info.CopyProtection!.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
#endif
break;
}
// Set the category if it's not overriden
#if NET48
info.CommonDiscInfo.Category = info.CommonDiscInfo.Category ?? DiscCategory.Games;
#else
info.CommonDiscInfo!.Category ??= DiscCategory.Games;
#endif
// Comments and contents have odd handling
if (string.IsNullOrEmpty(info.CommonDiscInfo.Comments))
@@ -642,8 +886,13 @@ namespace MPF.Core
/// <returns>Status of the LibCrypt data, if possible</returns>
private static void GetLibCryptDetected(SubmissionInfo info, string basePath)
{
bool? psLibCryptStatus = Protection.GetLibCryptDetected(basePath + ".sub");
#if NET48
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#else
info.CopyProtection ??= new CopyProtectionSection();
#endif
bool? psLibCryptStatus = Protection.GetLibCryptDetected(basePath + ".sub");
if (psLibCryptStatus == true)
{
// Guard against false positives
@@ -800,6 +1049,7 @@ namespace MPF.Core
bool reverseOrder = system.HasReversedRingcodes();
// Preamble for submission
#pragma warning disable IDE0028
var output = new List<string>
{
"Users who wish to submit this information to Redump must ensure that all of the fields below are accurate for the exact media they have.",
@@ -2161,11 +2411,7 @@ namespace MPF.Core
private async static Task<bool> FillFromId(RedumpHttpClient wc, SubmissionInfo info, int id, bool includeAllData)
{
// Ensure that required sections exist
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
if (info.CommonDiscInfo.ContentsSpecialFields == null) info.CommonDiscInfo.ContentsSpecialFields = new Dictionary<SiteCode, string>();
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
if (info.DumpersAndStatus == null) info.DumpersAndStatus = new DumpersAndStatusSection();
info = EnsureAllSections(info);
var discData = await wc.DownloadSingleSiteID(id);
if (string.IsNullOrEmpty(discData))
@@ -2185,7 +2431,7 @@ namespace MPF.Core
#if NET48
info.CommonDiscInfo.Title = title.Substring(0, firstParenLocation);
#else
info.CommonDiscInfo.Title = title[..firstParenLocation];
info.CommonDiscInfo!.Title = title[..firstParenLocation];
#endif
var subMatches = Constants.DiscNumberLetterRegex.Matches(title);
foreach (Match subMatch in subMatches.Cast<Match>())
@@ -2208,16 +2454,28 @@ namespace MPF.Core
// Otherwise, leave the title as-is
else
{
#if NET48
info.CommonDiscInfo.Title = title;
#else
info.CommonDiscInfo!.Title = title;
#endif
}
}
// Foreign Title
match = Constants.ForeignTitleRegex.Match(discData);
if (match.Success)
#if NET48
info.CommonDiscInfo.ForeignTitleNonLatin = WebUtility.HtmlDecode(match.Groups[1].Value);
#else
info.CommonDiscInfo!.ForeignTitleNonLatin = WebUtility.HtmlDecode(match.Groups[1].Value);
#endif
else
#if NET48
info.CommonDiscInfo.ForeignTitleNonLatin = null;
#else
info.CommonDiscInfo!.ForeignTitleNonLatin = null;
#endif
// Category
match = Constants.CategoryRegex.Match(discData);
@@ -2265,7 +2523,11 @@ namespace MPF.Core
}
// Version
#if NET48
if (info.VersionAndEditions.Version == null)
#else
if (info.VersionAndEditions!.Version == null)
#endif
{
match = Constants.VersionRegex.Match(discData);
if (match.Success)
@@ -2278,7 +2540,11 @@ namespace MPF.Core
{
// Start with any currently listed dumpers
var tempDumpers = new List<string>();
#if NET48
if (info.DumpersAndStatus.Dumpers != null && info.DumpersAndStatus.Dumpers.Length > 0)
#else
if (info.DumpersAndStatus!.Dumpers != null && info.DumpersAndStatus.Dumpers.Length > 0)
#endif
{
foreach (string dumper in info.DumpersAndStatus.Dumpers)
tempDumpers.Add(dumper);
@@ -2387,7 +2653,11 @@ namespace MPF.Core
}
// If we don't already have this site code, add it to the dictionary
#if NET48
if (!info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(siteCode.Value))
#else
if (!info.CommonDiscInfo.CommentsSpecialFields!.ContainsKey(siteCode.Value))
#endif
info.CommonDiscInfo.CommentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {commentLine.Replace(shortName, string.Empty).Trim()}";
// Otherwise, append the value to the existing key
@@ -2402,7 +2672,11 @@ namespace MPF.Core
{
if (addToLast && lastSiteCode != null)
{
#if NET48
if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.CommentsSpecialFields[lastSiteCode.Value]))
#else
if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.CommentsSpecialFields![lastSiteCode.Value]))
#endif
info.CommonDiscInfo.CommentsSpecialFields[lastSiteCode.Value] += "\n";
info.CommonDiscInfo.CommentsSpecialFields[lastSiteCode.Value] += commentLine;
@@ -2474,7 +2748,11 @@ namespace MPF.Core
lastSiteCode = siteCode;
// If we don't already have this site code, add it to the dictionary
#if NET48
if (!info.CommonDiscInfo.ContentsSpecialFields.ContainsKey(siteCode.Value))
#else
if (!info.CommonDiscInfo.ContentsSpecialFields!.ContainsKey(siteCode.Value))
#endif
info.CommonDiscInfo.ContentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {contentLine.Replace(shortName, string.Empty).Trim()}";
// A subset of tags can be multiline
@@ -2490,7 +2768,11 @@ namespace MPF.Core
{
if (addToLast && lastSiteCode != null)
{
#if NET48
if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.ContentsSpecialFields[lastSiteCode.Value]))
#else
if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.ContentsSpecialFields![lastSiteCode.Value]))
#endif
info.CommonDiscInfo.ContentsSpecialFields[lastSiteCode.Value] += "\n";
info.CommonDiscInfo.ContentsSpecialFields[lastSiteCode.Value] += contentLine;
@@ -2547,7 +2829,11 @@ namespace MPF.Core
return false;
// Set the current dumper based on username
#if NET48
if (info.DumpersAndStatus == null) info.DumpersAndStatus = new DumpersAndStatusSection();
#else
info.DumpersAndStatus ??= new DumpersAndStatusSection();
#endif
info.DumpersAndStatus.Dumpers = new string[] { options.RedumpUsername };
info.PartiallyMatchedIDs = new List<int>();
@@ -2983,6 +3269,7 @@ namespace MPF.Core
/// <remarks>TODO: This should move to Extensions at some point</remarks>
private static bool IsBoolean(SiteCode? siteCode)
{
#if NET48
switch (siteCode)
{
case SiteCode.PostgapType:
@@ -2991,6 +3278,14 @@ namespace MPF.Core
default:
return false;
}
#else
return siteCode switch
{
SiteCode.PostgapType => true,
SiteCode.VCD => true,
_ => false,
};
#endif
}
/// <summary>
@@ -3001,6 +3296,7 @@ namespace MPF.Core
/// <remarks>TODO: This should move to Extensions at some point</remarks>
private static bool IsMultiLine(SiteCode? siteCode)
{
#if NET48
switch (siteCode)
{
case SiteCode.Extras:
@@ -3019,6 +3315,24 @@ namespace MPF.Core
default:
return false;
}
#else
return siteCode switch
{
SiteCode.Extras => true,
SiteCode.Filename => true,
SiteCode.Games => true,
SiteCode.GameFootage => true,
SiteCode.Multisession => true,
SiteCode.NetYarozeGames => true,
SiteCode.Patches => true,
SiteCode.PlayableDemos => true,
SiteCode.RollingDemos => true,
SiteCode.Savegames => true,
SiteCode.TechDemos => true,
SiteCode.Videos => true,
_ => false,
};
#endif
}
/// <summary>

View File

@@ -5,7 +5,7 @@
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
<Copyright>Copyright (c)2019-2023</Copyright>
<VersionPrefix>2.7.1</VersionPrefix>
<VersionPrefix>2.7.2</VersionPrefix>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">

View File

@@ -13,8 +13,9 @@ using SabreTools.Models.CueSheets;
using SabreTools.RedumpLib.Data;
using Schemas;
// Ignore "Type or member is obsolete"
#pragma warning disable CS0618
#pragma warning disable CS0618 // Ignore "Type or member is obsolete"
#pragma warning disable IDE0051 // Remove unused private members
#pragma warning disable IDE0059 // Unnecessary assignment of a value
namespace MPF.Core.Modules.Aaru
{
@@ -273,7 +274,7 @@ namespace MPF.Core.Modules.Aaru
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
var missingFiles = new List<string>();
switch (this.Type)
{
case MediaType.CDROM:
@@ -332,9 +333,15 @@ namespace MPF.Core.Modules.Aaru
// TODO: Fill in submission info specifics for Aaru
var outputDirectory = Path.GetDirectoryName(basePath);
// Ensure that required sections exist
info = InfoTool.EnsureAllSections(info);
// TODO: Determine if there's an Aaru version anywhere
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
#if NET48
info.DumpingInfo.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#else
info.DumpingInfo!.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#endif
info.DumpingInfo.DumpingDate = GetFileModifiedDate(basePath + ".cicm.xml")?.ToString("yyyy-MM-dd HH:mm:ss");
// Deserialize the sidecar, if possible
@@ -366,8 +373,11 @@ namespace MPF.Core.Modules.Aaru
var datafile = GenerateDatafile(sidecar, basePath);
// Fill in the hash data
if (info.TracksAndWriteOffsets == null) info.TracksAndWriteOffsets = new TracksAndWriteOffsetsSection();
#if NET48
info.TracksAndWriteOffsets.ClrMameProData = GenerateDatfile(datafile);
#else
info.TracksAndWriteOffsets!.ClrMameProData = GenerateDatfile(datafile);
#endif
switch (this.Type)
{
@@ -381,8 +391,11 @@ namespace MPF.Core.Modules.Aaru
if (File.Exists(basePath + ".resume.xml"))
errorCount = GetErrorCount(basePath + ".resume.xml");
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
info.CommonDiscInfo.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString());
#else
info.CommonDiscInfo!.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString());
#endif
info.TracksAndWriteOffsets.Cuesheet = GenerateCuesheet(sidecar, basePath) ?? string.Empty;
@@ -394,12 +407,15 @@ namespace MPF.Core.Modules.Aaru
case MediaType.DVD:
case MediaType.HDDVD:
case MediaType.BluRay:
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
// Get the individual hash data, as per internal
if (GetISOHashValues(datafile, out long size, out var crc32, out var md5, out var sha1))
{
#if NET48
info.SizeAndChecksums.Size = size;
#else
info.SizeAndChecksums!.CRC32 = crc32;
#endif
info.SizeAndChecksums.CRC32 = crc32;
info.SizeAndChecksums.MD5 = md5;
info.SizeAndChecksums.SHA1 = sha1;
@@ -418,7 +434,11 @@ namespace MPF.Core.Modules.Aaru
if (this.Type == MediaType.DVD)
layerbreak = GetLayerbreak(sidecar) ?? string.Empty;
else if (this.Type == MediaType.BluRay)
#if NET48
layerbreak = info.SizeAndChecksums.Size > 25_025_314_816 ? "25025314816" : null;
#else
layerbreak = info.SizeAndChecksums!.Size > 25_025_314_816 ? "25025314816" : null;
#endif
// If we have a single-layer disc
if (string.IsNullOrWhiteSpace(layerbreak))
@@ -428,7 +448,11 @@ namespace MPF.Core.Modules.Aaru
// If we have a dual-layer disc
else
{
#if NET48
info.SizeAndChecksums.Layerbreak = Int64.Parse(layerbreak);
#else
info.SizeAndChecksums!.Layerbreak = Int64.Parse(layerbreak);
#endif
}
// TODO: Investigate XGD disc outputs
@@ -448,52 +472,60 @@ namespace MPF.Core.Modules.Aaru
case RedumpSystem.DVDAudio:
case RedumpSystem.DVDVideo:
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#if NET48
info.CopyProtection.Protection = GetDVDProtection(sidecar) ?? string.Empty;
#else
info.CopyProtection!.Protection = GetDVDProtection(sidecar) ?? string.Empty;
#endif
break;
case RedumpSystem.KonamiPython2:
if (GetPlayStationExecutableInfo(drive?.Letter, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = pythonTwoSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = pythonTwoSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? pythonTwoRegion;
info.CommonDiscInfo.EXEDateBuildDate = pythonTwoDate;
}
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
#if NET48
info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.MicrosoftXbox:
if (GetXgdAuxInfo(sidecar, out var xgd1DMIHash, out var xgd1PFIHash, out var xgd1SSHash, out var ss, out var xgd1SSVer))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DMIHash] = xgd1DMIHash ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = xgd1DMIHash ?? string.Empty;
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = xgd1PFIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd1SSHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd1SSVer ?? string.Empty;
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.SecuritySectorRanges = ss ?? string.Empty;
#else
info.Extras!.SecuritySectorRanges = ss ?? string.Empty;
#endif
}
if (GetXboxDMIInfo(sidecar, out var serial, out var version, out Region? region))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
info.CommonDiscInfo.Serial = serial ?? string.Empty;
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = version ?? string.Empty;
#else
info.CommonDiscInfo!.Serial = serial ?? string.Empty;
info.VersionAndEditions!.Version = version ?? string.Empty;
#endif
info.CommonDiscInfo.Region = region;
}
@@ -502,26 +534,30 @@ namespace MPF.Core.Modules.Aaru
case RedumpSystem.MicrosoftXbox360:
if (GetXgdAuxInfo(sidecar, out var xgd23DMIHash, out var xgd23PFIHash, out var xgd23SSHash, out var ss360, out var xgd23SSVer))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DMIHash] = xgd23DMIHash ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = xgd23DMIHash ?? string.Empty;
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = xgd23PFIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd23SSHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd23SSVer ?? string.Empty;
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.SecuritySectorRanges = ss360 ?? string.Empty;
#else
info.Extras!.SecuritySectorRanges = ss360 ?? string.Empty;
#endif
}
if (GetXbox360DMIInfo(sidecar, out var serial360, out var version360, out Region? region360))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
info.CommonDiscInfo.Serial = serial360 ?? string.Empty;
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = version360 ?? string.Empty;
#else
info.CommonDiscInfo!.Serial = serial360 ?? string.Empty;
info.VersionAndEditions!.Version = version360 ?? string.Empty;
#endif
info.CommonDiscInfo.Region = region360;
}
break;
@@ -530,13 +566,11 @@ namespace MPF.Core.Modules.Aaru
if (GetPlayStationExecutableInfo(drive?.Letter, out var playstationSerial, out Region? playstationRegion, out var playstationDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = playstationSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationRegion;
info.CommonDiscInfo.EXEDateBuildDate = playstationDate;
}
@@ -547,62 +581,61 @@ namespace MPF.Core.Modules.Aaru
if (GetPlayStationExecutableInfo(drive?.Letter, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationTwoSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = playstationTwoSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationTwoRegion;
info.CommonDiscInfo.EXEDateBuildDate = playstationTwoDate;
}
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
#if NET48
info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation3:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation4:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation5:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation5Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation5Serial(drive?.Letter) ?? string.Empty;
#endif
break;
}
// Fill in any artifacts that exist, Base64-encoded, if we need to
if (includeArtifacts)
{
#if NET48
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
#else
info.Artifacts ??= new Dictionary<string, string>();
#endif
if (File.Exists(basePath + ".cicm.xml"))
info.Artifacts["cicm"] = GetBase64(GetFullFile(basePath + ".cicm.xml")) ?? string.Empty;
if (File.Exists(basePath + ".ibg"))
@@ -625,7 +658,7 @@ namespace MPF.Core.Modules.Aaru
public override string? GenerateParameters()
#endif
{
List<string> parameters = new List<string>();
var parameters = new List<string>();
#region Pre-command flags
@@ -651,8 +684,12 @@ namespace MPF.Core.Modules.Aaru
#endregion
#if NET48
if (BaseCommand == null)
BaseCommand = CommandStrings.NONE;
#else
BaseCommand ??= CommandStrings.NONE;
#endif
if (!string.IsNullOrWhiteSpace(BaseCommand))
parameters.Add(BaseCommand);
@@ -1641,7 +1678,7 @@ namespace MPF.Core.Modules.Aaru
/// <inheritdoc/>
public override List<string> GetLogFilePaths(string basePath)
{
List<string> logFiles = new List<string>();
var logFiles = new List<string>();
switch (this.Type)
{
case MediaType.CDROM:
@@ -2340,7 +2377,7 @@ namespace MPF.Core.Modules.Aaru
return true;
}
#endregion
#endregion
#region Private Extra Methods
@@ -2350,9 +2387,9 @@ namespace MPF.Core.Modules.Aaru
/// <param name="baseCommand">Command string to normalize</param>
/// <returns>Normalized command</returns>
#if NET48
private string NormalizeCommand(List<string> parts, ref int start)
private static string NormalizeCommand(List<string> parts, ref int start)
#else
private string? NormalizeCommand(List<string> parts, ref int start)
private static string? NormalizeCommand(List<string> parts, ref int start)
#endif
{
// Invalid start means invalid command
@@ -2383,9 +2420,9 @@ namespace MPF.Core.Modules.Aaru
/// <param name="baseCommand">Command string to normalize</param>
/// <returns>Normalized command</returns>
#if NET48
private string NormalizeCommand(string baseCommand)
private static string NormalizeCommand(string baseCommand)
#else
private string? NormalizeCommand(string baseCommand)
private static string? NormalizeCommand(string baseCommand)
#endif
{
// If the base command is inavlid, just return nulls
@@ -2410,6 +2447,7 @@ namespace MPF.Core.Modules.Aaru
case CommandStrings.ArchivePrefixShort:
case CommandStrings.ArchivePrefixLong:
family = CommandStrings.ArchivePrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.ArchiveInfo:
@@ -2419,11 +2457,19 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.ArchiveInfo => CommandStrings.ArchiveInfo,
_ => null,
};
#endif
break;
case CommandStrings.DatabasePrefixShort:
case CommandStrings.DatabasePrefixLong:
family = CommandStrings.DatabasePrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.DatabaseStats:
@@ -2436,12 +2482,21 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.DatabaseStats => CommandStrings.DatabaseStats,
CommandStrings.DatabaseUpdate => CommandStrings.DatabaseUpdate,
_ => null,
};
#endif
break;
case CommandStrings.DevicePrefixShort:
case CommandStrings.DevicePrefixLong:
family = CommandStrings.DevicePrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.DeviceInfo:
@@ -2457,6 +2512,15 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.DeviceInfo => CommandStrings.DeviceInfo,
CommandStrings.DeviceList => CommandStrings.DeviceList,
CommandStrings.DeviceReport => CommandStrings.DeviceReport,
_ => null,
};
#endif
break;
@@ -2464,6 +2528,7 @@ namespace MPF.Core.Modules.Aaru
case CommandStrings.FilesystemPrefixShortAlt:
case CommandStrings.FilesystemPrefixLong:
family = CommandStrings.FilesystemPrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.FilesystemExtract:
@@ -2483,12 +2548,24 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.FilesystemExtract => CommandStrings.FilesystemExtract,
CommandStrings.FilesystemInfo => CommandStrings.FilesystemInfo,
CommandStrings.FilesystemListShort => CommandStrings.FilesystemListLong,
CommandStrings.FilesystemListLong => CommandStrings.FilesystemListLong,
CommandStrings.FilesystemOptions => CommandStrings.FilesystemOptions,
_ => null,
};
#endif
break;
case CommandStrings.ImagePrefixShort:
case CommandStrings.ImagePrefixLong:
family = CommandStrings.ImagePrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.ImageChecksumShort:
@@ -2527,12 +2604,31 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.ImageChecksumShort => CommandStrings.ImageChecksumLong,
CommandStrings.ImageChecksumLong => CommandStrings.ImageChecksumLong,
CommandStrings.ImageCompareShort => CommandStrings.ImageCompareLong,
CommandStrings.ImageCompareLong => CommandStrings.ImageCompareLong,
CommandStrings.ImageConvert => CommandStrings.ImageConvert,
CommandStrings.ImageCreateSidecar => CommandStrings.ImageCreateSidecar,
CommandStrings.ImageDecode => CommandStrings.ImageDecode,
CommandStrings.ImageEntropy => CommandStrings.ImageEntropy,
CommandStrings.ImageInfo => CommandStrings.ImageInfo,
CommandStrings.ImageOptions => CommandStrings.ImageOptions,
CommandStrings.ImagePrint => CommandStrings.ImagePrint,
CommandStrings.ImageVerify => CommandStrings.ImageVerify,
_ => null,
};
#endif
break;
case CommandStrings.MediaPrefixShort:
case CommandStrings.MediaPrefixLong:
family = CommandStrings.MediaPrefixLong;
#if NET48
switch (splitCommand[1])
{
case CommandStrings.MediaDump:
@@ -2548,6 +2644,15 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[1] switch
{
CommandStrings.MediaDump => CommandStrings.MediaDump,
CommandStrings.MediaInfo => CommandStrings.MediaInfo,
CommandStrings.MediaScan => CommandStrings.MediaScan,
_ => null,
};
#endif
break;
@@ -2562,6 +2667,7 @@ namespace MPF.Core.Modules.Aaru
else
{
family = null;
#if NET48
switch (splitCommand[0])
{
case CommandStrings.Configure:
@@ -2583,6 +2689,17 @@ namespace MPF.Core.Modules.Aaru
command = null;
break;
}
#else
command = splitCommand[0] switch
{
CommandStrings.Configure => CommandStrings.Configure,
CommandStrings.Formats => CommandStrings.Formats,
CommandStrings.ListEncodings => CommandStrings.ListEncodings,
CommandStrings.ListNamespaces => CommandStrings.ListNamespaces,
CommandStrings.Remote => CommandStrings.Remote,
_ => null,
};
#endif
}
// If the command itself is invalid, then return null
@@ -2606,7 +2723,7 @@ namespace MPF.Core.Modules.Aaru
/// <param name="trackType">TrackTypeTrackType to convert</param>
/// <param name="bytesPerSector">Sector size to help with specific subtypes</param>
/// <returns>CueTrackDataType representing the input data</returns>
private CueTrackDataType ConvertToDataType(TrackTypeTrackType trackType, uint bytesPerSector)
private static CueTrackDataType ConvertToDataType(TrackTypeTrackType trackType, uint bytesPerSector)
{
switch (trackType)
{
@@ -2637,7 +2754,7 @@ namespace MPF.Core.Modules.Aaru
/// </summary>
/// <param name="trackFlagsType">TrackFlagsType containing flag data</param>
/// <returns>CueTrackFlag representing the flags</returns>
private CueTrackFlag ConvertToTrackFlag(TrackFlagsType trackFlagsType)
private static CueTrackFlag ConvertToTrackFlag(TrackFlagsType trackFlagsType)
{
if (trackFlagsType == null)
return 0;
@@ -2663,9 +2780,9 @@ namespace MPF.Core.Modules.Aaru
/// <param name="basePath">Base path for determining file names</param>
/// <returns>String containing the cuesheet, null on error</returns>
#if NET48
private string GenerateCuesheet(CICMMetadataType cicmSidecar, string basePath)
private static string GenerateCuesheet(CICMMetadataType cicmSidecar, string basePath)
#else
private string? GenerateCuesheet(CICMMetadataType? cicmSidecar, string basePath)
private static string? GenerateCuesheet(CICMMetadataType? cicmSidecar, string basePath)
#endif
{
// If the object is null, we can't get information from it
@@ -2677,7 +2794,7 @@ namespace MPF.Core.Modules.Aaru
var cueFiles = new List<CueFile>();
var cueSheet = new CueSheet
{
Performer = string.Join(", ", cicmSidecar.Performer ?? new string[0]),
Performer = string.Join(", ", cicmSidecar.Performer ?? Array.Empty<string>()),
};
// Only care about OpticalDisc types
@@ -2702,7 +2819,7 @@ namespace MPF.Core.Modules.Aaru
foreach (TrackType track in opticalDisc.Track)
{
// Create cue track entry
CueTrack cueTrack = new CueTrack
var cueTrack = new CueTrack
{
Number = (int)(track.Sequence?.TrackNumber ?? 0),
DataType = ConvertToDataType(track.TrackType1, track.BytesPerSector),
@@ -2711,7 +2828,7 @@ namespace MPF.Core.Modules.Aaru
};
// Create cue file entry
CueFile cueFile = new CueFile
var cueFile = new CueFile
{
FileName = GenerateTrackName(basePath, (int)totalTracks, cueTrack.Number, opticalDisc.DiscType),
FileType = CueFileType.BINARY,
@@ -2930,8 +3047,8 @@ namespace MPF.Core.Modules.Aaru
return null;
// Required variables
Datafile datafile = new Datafile();
List<Rom> roms = new List<Rom>();
var datafile = new Datafile();
var roms = new List<Rom>();
// Process OpticalDisc, if possible
if (cicmSidecar.OpticalDisc != null && cicmSidecar.OpticalDisc.Length > 0)
@@ -3184,7 +3301,7 @@ namespace MPF.Core.Modules.Aaru
}
// Now generate the byte array data
List<byte> pvdData = new List<byte>();
var pvdData = new List<byte>();
pvdData.AddRange(new string(' ', 13).ToCharArray().Select(c => (byte)c));
pvdData.AddRange(GeneratePVDDateTimeBytes(creation));
pvdData.AddRange(GeneratePVDDateTimeBytes(modification));
@@ -3255,7 +3372,11 @@ namespace MPF.Core.Modules.Aaru
return null;
string pvdLine = $"{row} : ";
#if NET48
pvdLine += BitConverter.ToString(bytes.Slice(0, 8).ToArray()).Replace("-", " ");
#else
pvdLine += BitConverter.ToString(bytes[..8].ToArray()).Replace("-", " ");
#endif
pvdLine += " ";
pvdLine += BitConverter.ToString(bytes.Slice(8, 8).ToArray().ToArray()).Replace("-", " ");
pvdLine += " ";
@@ -3295,7 +3416,7 @@ namespace MPF.Core.Modules.Aaru
if (xtr == null)
return null;
XmlSerializer serializer = new XmlSerializer(typeof(CICMMetadataType));
var serializer = new XmlSerializer(typeof(CICMMetadataType));
return serializer.Deserialize(xtr) as CICMMetadataType;
}
@@ -3402,7 +3523,7 @@ namespace MPF.Core.Modules.Aaru
long? totalErrors = null;
// Parse the resume XML file
using (StreamReader sr = File.OpenText(resume))
using (var sr = File.OpenText(resume))
{
try
{

View File

@@ -47,7 +47,11 @@ namespace MPF.Core.Modules
/// <summary>
/// Set of flags to pass to the executable
/// </summary>
#if NET48
protected Dictionary<string, bool?> flags = new Dictionary<string, bool?>();
#else
protected Dictionary<string, bool?> flags = new();
#endif
protected internal IEnumerable<string> Keys => flags.Keys;
/// <summary>
@@ -239,7 +243,11 @@ namespace MPF.Core.Modules
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <returns>List of all log file paths, empty otherwise</returns>
#if NET48
public virtual List<string> GetLogFilePaths(string basePath) => new List<string>();
#else
public virtual List<string> GetLogFilePaths(string basePath) => new();
#endif
/// <summary>
/// Get the MediaType from the current set of parameters
@@ -1943,6 +1951,7 @@ namespace MPF.Core.Modules
/// <returns>Category, if possible</returns>
protected static DiscCategory? GetUMDCategory(string category)
{
#if NET48
switch (category)
{
case "GAME": return DiscCategory.Games;
@@ -1950,6 +1959,15 @@ namespace MPF.Core.Modules
case "AUDIO": return DiscCategory.Audio;
default: return null;
}
#else
return category switch
{
"GAME" => DiscCategory.Games,
"VIDEO" => DiscCategory.Video,
"AUDIO" => DiscCategory.Audio,
_ => null,
};
#endif
}
#endregion
@@ -1981,16 +1999,28 @@ namespace MPF.Core.Modules
{
case 'S':
// Check first two digits of S_PS serial
#if NET48
switch (serial.Substring(5, 2))
{
case "46": return Region.SouthKorea;
case "56": return Region.SouthKorea;
case "51": return Region.Asia;
case "56": return Region.SouthKorea;
case "55": return Region.Asia;
default: return Region.Japan;
}
#else
return serial.Substring(5, 2) switch
{
"46" => Region.SouthKorea,
"51" => Region.Asia,
"56" => Region.SouthKorea,
"55" => Region.Asia,
_ => Region.Japan,
};
#endif
case 'M':
// Check first three digits of S_PM serial
#if NET48
switch (serial.Substring(5, 3))
{
case "645": return Region.SouthKorea;
@@ -1998,6 +2028,15 @@ namespace MPF.Core.Modules
case "885": return Region.SouthKorea;
default: return Region.Japan; // Remaining S_PM serials may be Japan or Asia
}
#else
return serial.Substring(5, 3) switch
{
"645" => Region.SouthKorea,
"675" => Region.SouthKorea,
"885" => Region.SouthKorea,
_ => Region.Japan, // Remaining S_PM serials may be Japan or Asia
};
#endif
default: return Region.Japan;
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -7,6 +6,8 @@ using MPF.Core.Converters;
using MPF.Core.Data;
using SabreTools.RedumpLib.Data;
#pragma warning disable IDE0051 // Remove unused private members
namespace MPF.Core.Modules.CleanRip
{
/// <summary>
@@ -39,7 +40,7 @@ namespace MPF.Core.Modules.CleanRip
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
var missingFiles = new List<string>();
switch (this.Type)
{
case MediaType.DVD: // Only added here to help users; not strictly correct
@@ -70,9 +71,15 @@ namespace MPF.Core.Modules.CleanRip
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive? drive, bool includeArtifacts)
#endif
{
// Ensure that required sections exist
info = InfoTool.EnsureAllSections(info);
// TODO: Determine if there's a CleanRip version anywhere
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
#if NET48
info.DumpingInfo.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#else
info.DumpingInfo!.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#endif
info.DumpingInfo.DumpingDate = GetFileModifiedDate(basePath + "-dumpinfo.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
var datafile = GenerateCleanripDatafile(basePath + ".iso", basePath + "-dumpinfo.txt");
@@ -80,8 +87,11 @@ namespace MPF.Core.Modules.CleanRip
// Get the individual hash data, as per internal
if (GetISOHashValues(datafile, out long size, out var crc32, out var md5, out var sha1))
{
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
#if NET48
info.SizeAndChecksums.Size = size;
#else
info.SizeAndChecksums!.Size = size;
#endif
info.SizeAndChecksums.CRC32 = crc32;
info.SizeAndChecksums.MD5 = md5;
info.SizeAndChecksums.SHA1 = sha1;
@@ -98,23 +108,23 @@ namespace MPF.Core.Modules.CleanRip
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
if (File.Exists(basePath + ".bca"))
{
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.BCA = GetBCA(basePath + ".bca");
}
#else
info.Extras!.BCA = GetBCA(basePath + ".bca");
#endif
if (GetGameCubeWiiInformation(basePath + "-dumpinfo.txt", out Region? gcRegion, out var gcVersion, out var gcName))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
info.CommonDiscInfo.Region = gcRegion ?? info.CommonDiscInfo.Region;
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = gcVersion ?? info.VersionAndEditions.Version;
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.Region = gcRegion ?? info.CommonDiscInfo.Region;
info.VersionAndEditions.Version = gcVersion ?? info.VersionAndEditions.Version;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalName] = gcName ?? string.Empty;
#else
info.CommonDiscInfo!.Region = gcRegion ?? info.CommonDiscInfo.Region;
info.VersionAndEditions!.Version = gcVersion ?? info.VersionAndEditions.Version;
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.InternalName] = gcName ?? string.Empty;
#endif
}
break;
@@ -123,7 +133,12 @@ namespace MPF.Core.Modules.CleanRip
// Fill in any artifacts that exist, Base64-encoded, if we need to
if (includeArtifacts)
{
#if NET48
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
#else
info.Artifacts ??= new Dictionary<string, string>();
#endif
if (File.Exists(basePath + ".bca"))
info.Artifacts["bca"] = GetBase64(GetFullFile(basePath + ".bca", binary: true)) ?? string.Empty;
if (File.Exists(basePath + "-dumpinfo.txt"))
@@ -134,7 +149,7 @@ namespace MPF.Core.Modules.CleanRip
/// <inheritdoc/>
public override List<string> GetLogFilePaths(string basePath)
{
List<string> logFiles = new List<string>();
var logFiles = new List<string>();
switch (this.Type)
{
case MediaType.DVD: // Only added here to help users; not strictly correct
@@ -171,7 +186,7 @@ namespace MPF.Core.Modules.CleanRip
if (!File.Exists(dumpinfo))
return null;
using (StreamReader sr = File.OpenText(dumpinfo))
using (var sr = File.OpenText(dumpinfo))
{
long size = new FileInfo(iso).Length;
string crc = string.Empty;
@@ -190,12 +205,21 @@ namespace MPF.Core.Modules.CleanRip
var line = sr.ReadLine()?.Trim();
if (string.IsNullOrWhiteSpace(line))
continue;
#if NET48
else if (line.StartsWith("CRC32"))
crc = line.Substring(7).ToLowerInvariant();
else if (line.StartsWith("MD5"))
md5 = line.Substring(5);
else if (line.StartsWith("SHA-1"))
sha1 = line.Substring(7);
#else
else if (line.StartsWith("CRC32"))
crc = line[7..].ToLowerInvariant();
else if (line.StartsWith("MD5"))
md5 = line[5..];
else if (line.StartsWith("SHA-1"))
sha1 = line[7..];
#endif
}
return new Datafile
@@ -267,7 +291,7 @@ namespace MPF.Core.Modules.CleanRip
if (!File.Exists(dumpinfo))
return null;
using (StreamReader sr = File.OpenText(dumpinfo))
using (var sr = File.OpenText(dumpinfo))
{
long size = new FileInfo(iso).Length;
string crc = string.Empty;
@@ -286,12 +310,21 @@ namespace MPF.Core.Modules.CleanRip
var line = sr.ReadLine()?.Trim();
if (string.IsNullOrWhiteSpace(line))
continue;
#if NET48
else if (line.StartsWith("CRC32"))
crc = line.Substring(7).ToLowerInvariant();
else if (line.StartsWith("MD5"))
md5 = line.Substring(5);
else if (line.StartsWith("SHA-1"))
sha1 = line.Substring(7);
#else
else if (line.StartsWith("CRC32"))
crc = line[7..].ToLowerInvariant();
else if (line.StartsWith("MD5"))
md5 = line[5..];
else if (line.StartsWith("SHA-1"))
sha1 = line[7..];
#endif
}
return $"<rom name=\"{Path.GetFileName(iso)}\" size=\"{size}\" crc=\"{crc}\" md5=\"{md5}\" sha1=\"{sha1}\" />";
@@ -324,7 +357,7 @@ namespace MPF.Core.Modules.CleanRip
if (!File.Exists(dumpinfo))
return false;
using (StreamReader sr = File.OpenText(dumpinfo))
using (var sr = File.OpenText(dumpinfo))
{
try
{
@@ -342,15 +375,27 @@ namespace MPF.Core.Modules.CleanRip
}
else if (line.StartsWith("Version"))
{
#if NET48
version = line.Substring("Version: ".Length);
#else
version = line["Version: ".Length..];
#endif
}
else if (line.StartsWith("Internal Name"))
{
#if NET48
name = line.Substring("Internal Name: ".Length);
#else
name = line["Internal Name: ".Length..];
#endif
}
else if (line.StartsWith("Filename"))
{
#if NET48
string serial = line.Substring("Filename: ".Length);
#else
string serial = line["Filename: ".Length..];
#endif
// char gameType = serial[0];
// string gameid = serial[1] + serial[2];

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,13 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using BinaryObjectScanner.Protection;
using MPF.Core.Converters;
using MPF.Core.Data;
using MPF.Core.Utilities;
using SabreTools.RedumpLib.Data;
#pragma warning disable IDE0051 // Remove unused private members
namespace MPF.Core.Modules.Redumper
{
/// <summary>
@@ -293,9 +294,15 @@ namespace MPF.Core.Modules.Redumper
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive? drive, bool includeArtifacts)
#endif
{
// Ensure that required sections exist
info = InfoTool.EnsureAllSections(info);
// Get the dumping program and version
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
#if NET48
info.DumpingInfo.DumpingProgram = $"{EnumConverter.LongName(this.InternalProgram)} {GetVersion($"{basePath}.log") ?? "Unknown Version"}";
#else
info.DumpingInfo!.DumpingProgram = $"{EnumConverter.LongName(this.InternalProgram)} {GetVersion($"{basePath}.log") ?? "Unknown Version"}";
#endif
info.DumpingInfo.DumpingDate = GetFileModifiedDate($"{basePath}.log")?.ToString("yyyy-MM-dd HH:mm:ss");
// Fill in the hardware data
@@ -309,103 +316,133 @@ namespace MPF.Core.Modules.Redumper
switch (this.Type)
{
case MediaType.CDROM:
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
if (info.TracksAndWriteOffsets == null) info.TracksAndWriteOffsets = new TracksAndWriteOffsetsSection();
info.TracksAndWriteOffsets.ClrMameProData = GetDatfile($"{basePath}.log");
#else
info.Extras!.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
info.TracksAndWriteOffsets!.ClrMameProData = GetDatfile($"{basePath}.log");
#endif
info.TracksAndWriteOffsets.Cuesheet = GetFullFile($"{basePath}.cue") ?? string.Empty;
// Attempt to get the write offset
string cdWriteOffset = GetWriteOffset($"{basePath}.log") ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
info.CommonDiscInfo.RingWriteOffset = cdWriteOffset;
#else
info.CommonDiscInfo!.RingWriteOffset = cdWriteOffset;
#endif
info.TracksAndWriteOffsets.OtherWriteOffsets = cdWriteOffset;
// Attempt to get the error count
long errorCount = GetErrorCount($"{basePath}.log");
info.CommonDiscInfo.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString());
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
// Attempt to get multisession data
string cdMultiSessionInfo = GetMultisessionInformation($"{basePath}.log") ?? string.Empty;
if (!string.IsNullOrWhiteSpace(cdMultiSessionInfo))
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Multisession] = cdMultiSessionInfo;
#else
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.Multisession] = cdMultiSessionInfo;
#endif
// Attempt to get the universal hash, if it's an audio disc
if (this.System.IsAudio())
{
string universalHash = GetUniversalHash($"{basePath}.log") ?? string.Empty;
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash] = universalHash;
#else
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.UniversalHash] = universalHash;
#endif
}
// Attempt to get the non-zero data start, if it's an audio disc
if (this.System.IsAudio())
{
string ringNonZeroDataStart = GetRingNonZeroDataStart($"{basePath}.log") ?? string.Empty;
#if NET48
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.RingNonZeroDataStart] = ringNonZeroDataStart;
#else
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.RingNonZeroDataStart] = ringNonZeroDataStart;
#endif
}
break;
case MediaType.DVD:
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
if (info.TracksAndWriteOffsets == null) info.TracksAndWriteOffsets = new TracksAndWriteOffsetsSection();
info.TracksAndWriteOffsets.ClrMameProData = GetDatfile($"{basePath}.log");
#else
info.Extras!.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
info.TracksAndWriteOffsets!.ClrMameProData = GetDatfile($"{basePath}.log");
#endif
// Get the individual hash data, as per internal
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
if (GetISOHashValues(info.TracksAndWriteOffsets.ClrMameProData, out long size, out var crc32, out var md5, out var sha1))
{
#if NET48
info.SizeAndChecksums.Size = size;
#else
info.SizeAndChecksums!.Size = size;
#endif
info.SizeAndChecksums.CRC32 = crc32;
info.SizeAndChecksums.MD5 = md5;
info.SizeAndChecksums.SHA1 = sha1;
}
string layerbreak = GetLayerbreak($"{basePath}.log") ?? string.Empty;
#if NET48
info.SizeAndChecksums.Layerbreak = !string.IsNullOrEmpty(layerbreak) ? Int64.Parse(layerbreak) : default;
#else
info.SizeAndChecksums!.Layerbreak = !string.IsNullOrEmpty(layerbreak) ? Int64.Parse(layerbreak) : default;
#endif
break;
}
switch (this.System)
{
// case RedumpSystem.AppleMacintosh:
case RedumpSystem.AppleMacintosh:
case RedumpSystem.EnhancedCD:
case RedumpSystem.IBMPCcompatible:
case RedumpSystem.RainbowDisc:
case RedumpSystem.SonyElectronicBook:
// TODO: Support SecuROM data when generated
#if NET48
info.CopyProtection.SecuROMData = GetSecuROMData($"{basePath}.log") ?? string.Empty;
#else
info.CopyProtection!.SecuROMData = GetSecuROMData($"{basePath}.log") ?? string.Empty;
#endif
break;
case RedumpSystem.DVDAudio:
case RedumpSystem.DVDVideo:
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#if NET48
info.CopyProtection.Protection = GetDVDProtection($"{basePath}.log") ?? string.Empty;
#else
info.CopyProtection!.Protection = GetDVDProtection($"{basePath}.log") ?? string.Empty;
#endif
break;
case RedumpSystem.KonamiPython2:
if (GetPlayStationExecutableInfo(drive?.Letter, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = pythonTwoSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = pythonTwoSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? pythonTwoRegion;
info.CommonDiscInfo.EXEDateBuildDate = pythonTwoDate;
}
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
#if NET48
info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.MicrosoftXbox:
@@ -421,15 +458,13 @@ namespace MPF.Core.Modules.Redumper
break;
case RedumpSystem.SegaMegaCDSegaCD:
if (info.Extras == null) info.Extras = new ExtrasSection();
info.Extras.Header = GetSegaCDHeader($"{basePath}.log", out var scdBuildDate, out var scdSerial, out _) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.Extras.Header = GetSegaCDHeader($"{basePath}.log", out var scdBuildDate, out var scdSerial, out _) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = scdSerial ?? string.Empty;
#else
info.Extras!.Header = GetSegaCDHeader($"{basePath}.log", out var scdBuildDate, out var scdSerial, out _) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = scdSerial ?? string.Empty;
#endif
info.CommonDiscInfo.EXEDateBuildDate = scdBuildDate ?? string.Empty;
// TODO: Support region setting from parsed value
break;
@@ -451,8 +486,11 @@ namespace MPF.Core.Modules.Redumper
break;
case RedumpSystem.SegaSaturn:
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.Header = GetSaturnHeader($"{basePath}.log") ?? string.Empty;
#else
info.Extras!.Header = GetSaturnHeader($"{basePath}.log") ?? string.Empty;
#endif
// Take only the first 16 lines for Saturn
if (!string.IsNullOrEmpty(info.Extras.Header))
@@ -461,15 +499,13 @@ namespace MPF.Core.Modules.Redumper
if (GetSaturnBuildInfo(info.Extras.Header, out var saturnSerial, out var saturnVersion, out var buildDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = saturnSerial ?? string.Empty;
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = saturnVersion ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = saturnSerial ?? string.Empty;
info.VersionAndEditions!.Version = saturnVersion ?? string.Empty;
#endif
info.CommonDiscInfo.EXEDateBuildDate = buildDate ?? string.Empty;
}
@@ -479,21 +515,22 @@ namespace MPF.Core.Modules.Redumper
if (GetPlayStationExecutableInfo(drive?.Letter, out var playstationSerial, out Region? playstationRegion, out var playstationDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = playstationSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationRegion;
info.CommonDiscInfo.EXEDateBuildDate = playstationDate;
}
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
#if NET48
info.CopyProtection.AntiModchip = GetPlayStationAntiModchipDetected($"{basePath}.log").ToYesNo();
if (info.EDC == null) info.EDC = new EDCSection();
info.EDC.EDC = GetPlayStationEDCStatus($"{basePath}.log").ToYesNo();
#else
info.CopyProtection!.AntiModchip = GetPlayStationAntiModchipDetected($"{basePath}.log").ToYesNo();
info.EDC!.EDC = GetPlayStationEDCStatus($"{basePath}.log").ToYesNo();
#endif
info.CopyProtection.LibCrypt = GetPlayStationLibCryptStatus($"{basePath}.log").ToYesNo();
info.CopyProtection.LibCryptData = GetPlayStationLibCryptData($"{basePath}.log");
break;
@@ -502,62 +539,62 @@ namespace MPF.Core.Modules.Redumper
if (GetPlayStationExecutableInfo(drive?.Letter, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate))
{
// Ensure internal serial is pulled from local data
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationTwoSerial ?? string.Empty;
#else
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = playstationTwoSerial ?? string.Empty;
#endif
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationTwoRegion;
info.CommonDiscInfo.EXEDateBuildDate = playstationTwoDate;
}
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
#if NET48
info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation2Version(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation3:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation3Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation4:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation4Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? string.Empty;
#endif
break;
case RedumpSystem.SonyPlayStation5:
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
#else
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
#endif
info.VersionAndEditions.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation5Serial(drive?.Letter) ?? string.Empty;
#else
info.VersionAndEditions!.Version = GetPlayStation5Version(drive?.Letter) ?? string.Empty;
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = GetPlayStation5Serial(drive?.Letter) ?? string.Empty;
#endif
break;
}
// Fill in any artifacts that exist, Base64-encoded, if we need to
if (includeArtifacts)
{
#if NET48
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
#else
info.Artifacts ??= new Dictionary<string, string>();
#endif
if (File.Exists($"{basePath}.cdtext"))
info.Artifacts["cdtext"] = GetBase64(GetFullFile($"{basePath}.cdtext")) ?? string.Empty;
if (File.Exists($"{basePath}.cue"))
@@ -998,6 +1035,7 @@ namespace MPF.Core.Modules.Redumper
switch (this.Type)
{
case MediaType.CDROM:
#if NET48
switch (this.System)
{
case RedumpSystem.SuperAudioCD:
@@ -1007,6 +1045,13 @@ namespace MPF.Core.Modules.Redumper
ModeValues = new List<string> { CommandStrings.CD };
break;
}
#else
ModeValues = this.System switch
{
RedumpSystem.SuperAudioCD => new List<string> { CommandStrings.SACD },
_ => new List<string> { CommandStrings.CD },
};
#endif
break;
case MediaType.DVD:
ModeValues = new List<string> { CommandStrings.DVD };
@@ -1330,7 +1375,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1376,7 +1421,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1428,7 +1473,7 @@ namespace MPF.Core.Modules.Redumper
#else
string? region = null, rceProtection = null, copyrightProtectionSystemType = null, vobKeys = null, decryptedDiscKey = null;
#endif
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1529,7 +1574,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return -1;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1580,7 +1625,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1659,7 +1704,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1725,7 +1770,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1765,7 +1810,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1809,7 +1854,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1851,7 +1896,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1895,7 +1940,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -1941,7 +1986,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2033,7 +2078,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2075,6 +2120,56 @@ namespace MPF.Core.Modules.Redumper
}
}
/// <summary>
/// Get the header from a Saturn, if possible
/// </summary>
/// <param name="log">Log file location</param>
/// <returns>Header as a byte array if possible, null on error</returns>
#if NET48
private static string GetSecuROMData(string log)
#else
private static string? GetSecuROMData(string log)
#endif
{
// If the file doesn't exist, we can't get info from it
if (!File.Exists(log))
return null;
using (var sr = File.OpenText(log))
{
try
{
// Fast forward to the SecuROM line
while (!sr.EndOfStream && sr.ReadLine()?.TrimStart()?.StartsWith("SecuROM [") == false) ;
if (sr.EndOfStream)
return null;
var lines = new List<string>();
while (!sr.EndOfStream)
{
var line = sr.ReadLine()?.TrimStart();
// Skip the "version"/"scheme" line
if (line?.StartsWith("version:") == true || line?.StartsWith("scheme:") == true)
continue;
// Only read until while there are MSF lines
if (line?.StartsWith("MSF:") != true)
break;
lines.Add(line);
}
return string.Join("\n", lines).TrimEnd('\n');
}
catch
{
// We don't care what the exception is right now
return null;
}
}
}
/// <summary>
/// Get the header from a Sega CD / Mega CD, if possible
/// </summary>
@@ -2093,7 +2188,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2185,7 +2280,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2232,7 +2327,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return null;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2283,7 +2378,7 @@ namespace MPF.Core.Modules.Redumper
// redumper v2022.10.28 [Oct 28 2022, 05:41:43] (print usage: --help,-h)
// redumper v2022.12.22 build_87 [Dec 22 2022, 01:56:26]
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{
@@ -2327,7 +2422,7 @@ namespace MPF.Core.Modules.Redumper
if (!File.Exists(log))
return false;
using (StreamReader sr = File.OpenText(log))
using (var sr = File.OpenText(log))
{
try
{

View File

@@ -38,7 +38,7 @@ namespace MPF.Core.Modules.UmdImageCreator
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
var missingFiles = new List<string>();
switch (this.Type)
{
case MediaType.UMD:
@@ -71,22 +71,34 @@ namespace MPF.Core.Modules.UmdImageCreator
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive? drive, bool includeArtifacts)
#endif
{
// Ensure that required sections exist
info = InfoTool.EnsureAllSections(info);
// TODO: Determine if there's a UMDImageCreator version anywhere
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
#if NET48
info.DumpingInfo.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#else
info.DumpingInfo!.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
#endif
info.DumpingInfo.DumpingDate = GetFileModifiedDate(basePath + "_disc.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
// Extract info based generically on MediaType
switch (this.Type)
{
case MediaType.UMD:
if (info.Extras == null) info.Extras = new ExtrasSection();
#if NET48
info.Extras.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty;
#else
info.Extras!.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty;
#endif
if (GetFileHashes(basePath + ".iso", out long filesize, out var crc32, out var md5, out var sha1))
{
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
#if NET48
info.SizeAndChecksums.Size = filesize;
#else
info.SizeAndChecksums!.Size = filesize;
#endif
info.SizeAndChecksums.CRC32 = crc32;
info.SizeAndChecksums.MD5 = md5;
info.SizeAndChecksums.SHA1 = sha1;
@@ -94,13 +106,17 @@ namespace MPF.Core.Modules.UmdImageCreator
if (GetUMDAuxInfo(basePath + "_disc.txt", out var title, out DiscCategory? umdcat, out var umdversion, out var umdlayer, out long umdsize))
{
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
#if NET48
info.CommonDiscInfo.Title = title ?? string.Empty;
info.CommonDiscInfo.Category = umdcat ?? DiscCategory.Games;
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
info.VersionAndEditions.Version = umdversion ?? string.Empty;
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
info.SizeAndChecksums.Size = umdsize;
#else
info.CommonDiscInfo!.Title = title ?? string.Empty;
info.CommonDiscInfo.Category = umdcat ?? DiscCategory.Games;
info.VersionAndEditions!.Version = umdversion ?? string.Empty;
info.SizeAndChecksums!.Size = umdsize;
#endif
if (!string.IsNullOrWhiteSpace(umdlayer))
info.SizeAndChecksums.Layerbreak = Int64.Parse(umdlayer ?? "-1");
@@ -112,7 +128,12 @@ namespace MPF.Core.Modules.UmdImageCreator
// Fill in any artifacts that exist, Base64-encoded, if we need to
if (includeArtifacts)
{
#if NET48
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
#else
info.Artifacts ??= new Dictionary<string, string>();
#endif
if (File.Exists(basePath + "_disc.txt"))
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt")) ?? string.Empty;
if (File.Exists(basePath + "_drive.txt"))
@@ -129,7 +150,7 @@ namespace MPF.Core.Modules.UmdImageCreator
/// <inheritdoc/>
public override List<string> GetLogFilePaths(string basePath)
{
List<string> logFiles = new List<string>();
var logFiles = new List<string>();
switch (this.Type)
{
case MediaType.UMD:
@@ -169,7 +190,7 @@ namespace MPF.Core.Modules.UmdImageCreator
if (!File.Exists(mainInfo))
return null;
using (StreamReader sr = File.OpenText(mainInfo))
using (var sr = File.OpenText(mainInfo))
{
try
{
@@ -211,7 +232,7 @@ namespace MPF.Core.Modules.UmdImageCreator
if (!File.Exists(disc))
return false;
using (StreamReader sr = File.OpenText(disc))
using (var sr = File.OpenText(disc))
{
try
{
@@ -224,7 +245,11 @@ namespace MPF.Core.Modules.UmdImageCreator
break;
if (line.StartsWith("TITLE") && title == null)
#if NET48
title = line.Substring("TITLE: ".Length);
#else
title = line["TITLE: ".Length..];
#endif
else if (line.StartsWith("DISC_VERSION") && umdversion == null)
umdversion = line.Split(' ')[1];
else if (line.StartsWith("pspUmdTypes"))
@@ -236,7 +261,7 @@ namespace MPF.Core.Modules.UmdImageCreator
}
// If the L0 length is the size of the full disc, there's no layerbreak
if (Int64.TryParse(umdlayer, out long umdlayerValue) && umdlayerValue * 2048 == umdsize)
if (Int64.TryParse(umdlayer, out long umdlayerValue) && umdlayerValue * 2048 == umdsize)
umdlayer = null;
return true;

View File

@@ -550,6 +550,7 @@ namespace MPF.Core.UI.ViewModels
StartStopButtonEnabled = true;
StartStopButtonText = Interface.StartDumping;
MediaScanButtonEnabled = true;
EnableParametersCheckBoxEnabled = true;
LogPanelExpanded = _options.OpenLogWindowAtStartup;
MediaTypes = new List<Element<MediaType>>();
@@ -1591,7 +1592,8 @@ namespace MPF.Core.UI.ViewModels
return Drives != null
&& Drives.Count > 0
&& this.CurrentSystem != null
&& this.CurrentMediaType != null;
&& this.CurrentMediaType != null
&& Tools.ProgramSupportsMedia(this.CurrentProgram, this.CurrentMediaType);
}
/// <summary>

View File

@@ -185,7 +185,7 @@ namespace MPF.Core.Utilities
}
// Include seed info file
if (args[startIndex].StartsWith("-l=") || args[startIndex].StartsWith("--load-seed="))
else if (args[startIndex].StartsWith("-l=") || args[startIndex].StartsWith("--load-seed="))
{
string seedInfo = args[startIndex].Split('=')[1];
info = InfoTool.CreateFromFile(seedInfo);

View File

@@ -84,6 +84,7 @@ namespace MPF.Core.Utilities
return Result.Failure("Please select a valid system");
// If we're on an unsupported type, update the status accordingly
#if NET48
switch (type)
{
// Fully supported types
@@ -116,6 +117,128 @@ namespace MPF.Core.Utilities
default:
return Result.Failure($"{type.LongName()} media are not supported for dumping");
}
#else
return type switch
{
// Fully supported types
MediaType.BluRay
or MediaType.CDROM
or MediaType.DVD
or MediaType.FloppyDisk
or MediaType.HardDisk
or MediaType.CompactFlash
or MediaType.SDCard
or MediaType.FlashDrive
or MediaType.HDDVD => Result.Success($"{type.LongName()} ready to dump"),
// Partially supported types
MediaType.GDROM
or MediaType.NintendoGameCubeGameDisc
or MediaType.NintendoWiiOpticalDisc => Result.Success($"{type.LongName()} partially supported for dumping"),
// Special case for other supported tools
MediaType.UMD => Result.Failure($"{type.LongName()} supported for submission info parsing"),
// Specifically unknown type
MediaType.NONE => Result.Failure($"Please select a valid media type"),
// Undumpable but recognized types
_ => Result.Failure($"{type.LongName()} media are not supported for dumping"),
};
#endif
}
/// <summary>
/// Returns false if a given InternalProgram does not support a given MediaType
/// </summary>
public static bool ProgramSupportsMedia(InternalProgram program, MediaType? type)
{
// If the media type is not set, return false
if (type == null || type == MediaType.NONE)
return false;
#if NET48
switch (program)
{
case InternalProgram.Redumper:
switch (type)
{
// Formats considered at least partially dumpable by Redumper
case MediaType.CDROM:
case MediaType.DVD:
case MediaType.GDROM:
return true;
// All other formats considered unsupported
default:
return false;
}
case InternalProgram.Aaru:
case InternalProgram.DiscImageCreator:
switch (type)
{
// Formats considered at least partially supported
case MediaType.BluRay:
case MediaType.CDROM:
case MediaType.DVD:
case MediaType.FloppyDisk:
case MediaType.HardDisk:
case MediaType.CompactFlash:
case MediaType.SDCard:
case MediaType.FlashDrive:
case MediaType.HDDVD:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
return true;
// All other formats considered unsupported
default:
return false;
}
// All other InternalPrograms are not used for dumping
default:
return false;
}
#else
switch (program)
{
case InternalProgram.Redumper:
return type switch
{
// Formats considered at least partially supported by Redumper
MediaType.CDROM
or MediaType.DVD
or MediaType.GDROM => true,
// All other formats considered unsupported
_ => false,
};
case InternalProgram.Aaru:
case InternalProgram.DiscImageCreator:
return type switch
{
// Formats considered at least partially supported by MPF
MediaType.BluRay
or MediaType.CDROM
or MediaType.DVD
or MediaType.GDROM
or MediaType.FloppyDisk
or MediaType.CompactFlash
or MediaType.SDCard
or MediaType.FlashDrive
or MediaType.HardDisk
or MediaType.HDDVD
or MediaType.NintendoGameCubeGameDisc
or MediaType.NintendoWiiOpticalDisc => true,
// All other formats considered unsupported
_ => false,
};
// All other InternalPrograms are not supported for dumping
default:
return false;
}
#endif
}
#endregion
@@ -197,7 +320,7 @@ namespace MPF.Core.Utilities
#endif
{
#if NET48
using (System.Net.WebClient wc = new System.Net.WebClient())
using (var wc = new System.Net.WebClient())
{
wc.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0";
@@ -211,7 +334,7 @@ namespace MPF.Core.Utilities
return (latestTag, releaseUrl);
}
#else
using (System.Net.Http.HttpClient hc = new System.Net.Http.HttpClient())
using (var hc = new System.Net.Http.HttpClient())
{
// TODO: Figure out a better way than having this hardcoded...
string url = "https://api.github.com/repos/SabreTools/MPF/releases/latest";

View File

@@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
<Copyright>Copyright (c)2019-2023</Copyright>
<VersionPrefix>2.7.1</VersionPrefix>
<VersionPrefix>2.7.2</VersionPrefix>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">

View File

@@ -381,7 +381,7 @@
</TabItem>
<TabItem Header="Redumper" Style="{DynamicResource CustomTabItemStyle}">
<UniformGrid Columns="2" Rows="2">
<UniformGrid Columns="2" Rows="3">
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"
IsChecked="{Binding Options.RedumperEnableDebug}"
ToolTip="Enable debug output in logs" Margin="0,4"

View File

@@ -11,7 +11,7 @@
<Description>Frontend for various dumping programs</Description>
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
<Copyright>Copyright (c)2019-2023</Copyright>
<VersionPrefix>2.7.1</VersionPrefix>
<VersionPrefix>2.7.2</VersionPrefix>
<InternalsVisibleTo>MPF.Test</InternalsVisibleTo>
</PropertyGroup>

View File

@@ -1,5 +1,5 @@
# version format
version: 2.7.1-{build}
version: 2.7.2-{build}
# pull request template
pull_requests:
@@ -56,8 +56,8 @@ after_build:
- 7z e DiscImageCreator_20230606.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Creator Release_ANSI\*
# Redumper
- ps: appveyor DownloadFile https://github.com/superg/redumper/releases/download/build_221/redumper-2023.10.02_build221-win64.zip
- 7z e redumper-2023.10.02_build221-win64.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Redumper redumper-2023.10.02_build221-win64\bin\*
- ps: appveyor DownloadFile https://github.com/superg/redumper/releases/download/build_230/redumper-2023.10.14_build230-win64.zip
- 7z e redumper-2023.10.14_build230-win64.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Redumper redumper-2023.10.14_build230-win64\bin\*
# Create MPF Debug archives
- cd %APPVEYOR_BUILD_FOLDER%\MPF\bin\Debug\net6.0-windows\win-x64\publish\