mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Support checking Redumper DAT from zip; add tests
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
- Fix lines wiped before displayed
|
||||
- Update redumper to build 565
|
||||
- Close the log archive, if it exists
|
||||
- Support checking Redumper DAT from zip; add tests
|
||||
|
||||
### 3.3.0 (2025-01-03)
|
||||
|
||||
|
||||
@@ -127,6 +127,16 @@ namespace MPF.Processors.Test
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAnyFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM-zip");
|
||||
string outputFilename = "test.aaruf";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.FoundAnyFiles(outputDirectory, outputFilename);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
@@ -112,6 +112,16 @@ namespace MPF.Processors.Test
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAnyFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD-zip");
|
||||
string outputFilename = "test.iso";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.FoundAnyFiles(outputDirectory, outputFilename);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
@@ -181,6 +181,16 @@ namespace MPF.Processors.Test
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAnyFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM-zip");
|
||||
string outputFilename = "test.cue";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.FoundAnyFiles(outputDirectory, outputFilename);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
@@ -91,6 +91,16 @@ namespace MPF.Processors.Test
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAnyFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay-zip");
|
||||
string outputFilename = "test.iso";
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.FoundAnyFiles(outputDirectory, outputFilename);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MPF.Processors.Test
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
|
||||
var actual = processor.GetOutputFiles(outputDirectory, outputFilename);
|
||||
Assert.Equal(15, actual.Count);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -100,6 +100,16 @@ namespace MPF.Processors.Test
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAllFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM-zip");
|
||||
string outputFilename = "test.cue";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.FoundAllFiles(outputDirectory, outputFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FoundAnyFiles
|
||||
@@ -145,7 +155,7 @@ namespace MPF.Processors.Test
|
||||
string outputFilename = "test.cue";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(outputDirectory, outputFilename);
|
||||
Assert.Equal(9, actual.Count);
|
||||
Assert.Equal(10, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -193,7 +203,7 @@ namespace MPF.Processors.Test
|
||||
string outputFilename = "test.cue";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(outputDirectory, outputFilename);
|
||||
Assert.Equal(9, actual.Count);
|
||||
Assert.Equal(10, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM-zip/test.aaruf
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM-zip/test.aaruf
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
BIN
MPF.Processors.Test/TestData/Aaru/CDROM-zip/test_logs.zip
Normal file
BIN
MPF.Processors.Test/TestData/Aaru/CDROM-zip/test_logs.zip
Normal file
Binary file not shown.
1
MPF.Processors.Test/TestData/CleanRip/DVD-zip/test.iso
Normal file
1
MPF.Processors.Test/TestData/CleanRip/DVD-zip/test.iso
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
BIN
MPF.Processors.Test/TestData/CleanRip/DVD-zip/test_logs.zip
Normal file
BIN
MPF.Processors.Test/TestData/CleanRip/DVD-zip/test_logs.zip
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1,3 @@
|
||||
<< GetDVDProtection >>
|
||||
DecryptedDiscKey[020]: No Key
|
||||
LBA: 0, Filename: FILE, No TitleKey
|
||||
Binary file not shown.
1
MPF.Processors.Test/TestData/PS3CFW/BluRay-zip/test.iso
Normal file
1
MPF.Processors.Test/TestData/PS3CFW/BluRay-zip/test.iso
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
BIN
MPF.Processors.Test/TestData/PS3CFW/BluRay-zip/test_logs.zip
Normal file
BIN
MPF.Processors.Test/TestData/PS3CFW/BluRay-zip/test_logs.zip
Normal file
Binary file not shown.
1
MPF.Processors.Test/TestData/Redumper/CDROM-zip/test.cue
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM-zip/test.cue
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
BIN
MPF.Processors.Test/TestData/Redumper/CDROM-zip/test_logs.zip
Normal file
BIN
MPF.Processors.Test/TestData/Redumper/CDROM-zip/test_logs.zip
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
Binary file not shown.
@@ -67,6 +67,16 @@ namespace MPF.Processors.Test
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAllFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD-zip");
|
||||
string outputFilename = "test.iso";
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.FoundAllFiles(outputDirectory, outputFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FoundAnyFiles
|
||||
|
||||
@@ -67,6 +67,16 @@ namespace MPF.Processors.Test
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundAllFiles_ValidZip_Empty()
|
||||
{
|
||||
string? outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD-zip");
|
||||
string outputFilename = "test.iso";
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.FoundAllFiles(outputDirectory, outputFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FoundAnyFiles
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using SabreTools.Hashing;
|
||||
@@ -427,16 +431,21 @@ namespace MPF.Processors
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM:
|
||||
List<OutputFile> cdrom = [
|
||||
// .asus is obsolete: newer redumper produces .cache instead
|
||||
new($"{outputFilename}.asus", OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
"asus"),
|
||||
new($"{outputFilename}.atip", OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
"atip"),
|
||||
new($"{outputFilename}.cache", OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
"cache"),
|
||||
new($"{outputFilename}.cdtext", OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
"cdtext"),
|
||||
new($"{outputFilename}.cue", OutputFileFlags.Required),
|
||||
new($"{outputFilename}.flip", OutputFileFlags.None),
|
||||
new($"{outputFilename}.fulltoc", OutputFileFlags.Required
|
||||
| OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
@@ -450,7 +459,6 @@ namespace MPF.Processors
|
||||
new($"{outputFilename}.pma", OutputFileFlags.Binary
|
||||
| OutputFileFlags.Zippable,
|
||||
"pma"),
|
||||
new([$"{outputFilename}.flip"], OutputFileFlags.None),
|
||||
new([$"{outputFilename}.scram", $"{outputFilename}.scrap"], OutputFileFlags.Required
|
||||
| OutputFileFlags.Deleteable),
|
||||
new($"{outputFilename}.state", OutputFileFlags.Required
|
||||
@@ -625,7 +633,45 @@ namespace MPF.Processors
|
||||
/// </summary>
|
||||
/// <param name="log">Log file location</param>
|
||||
private static bool DatfileExists(string log)
|
||||
=> GetDatfile(log) != null;
|
||||
{
|
||||
// Uncompressed outputs
|
||||
if (GetDatfile(log) != null)
|
||||
return true;
|
||||
|
||||
// Check for the log file
|
||||
string outputFilename = Path.GetFileName(log);
|
||||
string? outputDirectory = Path.GetDirectoryName(log);
|
||||
string basePath = Path.GetFileNameWithoutExtension(outputFilename);
|
||||
if (!string.IsNullOrEmpty(outputDirectory))
|
||||
basePath = Path.Combine(outputDirectory, basePath);
|
||||
|
||||
#if NET20 || NET35 || NET40
|
||||
// Assume the zipfile has the file in it
|
||||
return File.Exists($"{basePath}_logs.zip");
|
||||
#else
|
||||
// If the zipfile doesn't exist
|
||||
if (!File.Exists($"{basePath}_logs.zip"))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
// Try to open the archive
|
||||
using ZipArchive archive = ZipFile.OpenRead($"{basePath}_logs.zip");
|
||||
|
||||
// Get the log entry and check it, if possible
|
||||
var entry = archive.GetEntry(outputFilename);
|
||||
if (entry == null)
|
||||
return false;
|
||||
|
||||
using var sr = new StreamReader(entry.Open());
|
||||
return GetDatfile(sr) != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies a file with the header removed
|
||||
@@ -769,6 +815,24 @@ namespace MPF.Processors
|
||||
try
|
||||
{
|
||||
using var sr = File.OpenText(log);
|
||||
return GetDatfile(sr);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the datfile from the input file, if possible
|
||||
/// </summary>
|
||||
/// <param name="sr">StreamReader representing the input file</param>
|
||||
/// <returns>Newline-delimited datfile if possible, null on error</returns>
|
||||
internal static string? GetDatfile(StreamReader sr)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? datString = null;
|
||||
|
||||
// Find all occurrences of the hash information
|
||||
|
||||
Reference in New Issue
Block a user