mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Merge pull request #269 from SabreTools/logjam
Add option to compress log files after dumping
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
- Implement internal log queue
|
||||
- It's a secret...
|
||||
- Updated to DIC version 20210401
|
||||
- Support log file compression
|
||||
|
||||
### 1.18 (2020-11-10)
|
||||
- Add more information extraction and generation for Aaru
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace MPF.Check
|
||||
string username = null, password = null;
|
||||
string internalProgram = "DiscImageCreator";
|
||||
string path = string.Empty;
|
||||
bool scan = false;
|
||||
bool scan = false, compress = false;
|
||||
|
||||
// Loop through and process options
|
||||
int startIndex = 2;
|
||||
@@ -113,6 +113,12 @@ namespace MPF.Check
|
||||
scan = true;
|
||||
}
|
||||
|
||||
// Compress log and extraneous files
|
||||
else if (args[startIndex].StartsWith("-z") || args[startIndex].StartsWith("--zip"))
|
||||
{
|
||||
compress = true;
|
||||
}
|
||||
|
||||
// Default, we fall out
|
||||
else
|
||||
{
|
||||
@@ -160,6 +166,7 @@ namespace MPF.Check
|
||||
InternalProgram = Converters.ToInternalProgram(internalProgram),
|
||||
ScanForProtection = scan && !string.IsNullOrWhiteSpace(path),
|
||||
PromptForDiscInformation = false,
|
||||
CompressLogFiles = compress,
|
||||
|
||||
RedumpUsername = username,
|
||||
RedumpPassword = password,
|
||||
@@ -200,6 +207,7 @@ namespace MPF.Check
|
||||
Console.WriteLine("-u, --use <program> Dumping program output type");
|
||||
Console.WriteLine("-p, --path <drivepath> Physical drive path for additional checks");
|
||||
Console.WriteLine("-s, --scan Enable copy protection scan (requires --path)");
|
||||
Console.WriteLine("-z, --zip Enable log file compression");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace MPF.Aaru
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive)
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts)
|
||||
{
|
||||
// TODO: Fill in submission info specifics for Aaru
|
||||
string outputDirectory = Path.GetDirectoryName(basePath);
|
||||
@@ -365,19 +365,22 @@ namespace MPF.Aaru
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill in any artifacts that exist, Base64-encoded
|
||||
if (File.Exists(basePath + ".cicm.xml"))
|
||||
info.Artifacts["cicm"] = GetBase64(GetFullFile(basePath + ".cicm.xml"));
|
||||
if (File.Exists(basePath + ".ibg"))
|
||||
info.Artifacts["ibg"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".ibg"));
|
||||
if (File.Exists(basePath + ".log"))
|
||||
info.Artifacts["log"] = GetBase64(GetFullFile(basePath + ".log"));
|
||||
if (File.Exists(basePath + ".mhddlog.bin"))
|
||||
info.Artifacts["mhddlog_bin"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".mhddlog.bin"));
|
||||
if (File.Exists(basePath + ".resume.xml"))
|
||||
info.Artifacts["resume"] = GetBase64(GetFullFile(basePath + ".resume.xml"));
|
||||
if (File.Exists(basePath + ".sub.log"))
|
||||
info.Artifacts["sub_log"] = GetBase64(GetFullFile(basePath + ".sub.log"));
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
if (File.Exists(basePath + ".cicm.xml"))
|
||||
info.Artifacts["cicm"] = GetBase64(GetFullFile(basePath + ".cicm.xml"));
|
||||
if (File.Exists(basePath + ".ibg"))
|
||||
info.Artifacts["ibg"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".ibg"));
|
||||
if (File.Exists(basePath + ".log"))
|
||||
info.Artifacts["log"] = GetBase64(GetFullFile(basePath + ".log"));
|
||||
if (File.Exists(basePath + ".mhddlog.bin"))
|
||||
info.Artifacts["mhddlog_bin"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".mhddlog.bin"));
|
||||
if (File.Exists(basePath + ".resume.xml"))
|
||||
info.Artifacts["resume"] = GetBase64(GetFullFile(basePath + ".resume.xml"));
|
||||
if (File.Exists(basePath + ".sub.log"))
|
||||
info.Artifacts["sub_log"] = GetBase64(GetFullFile(basePath + ".sub.log"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -1030,6 +1033,48 @@ namespace MPF.Aaru
|
||||
/// <inheritdoc/>
|
||||
public override string GetDefaultExtension(MediaType? mediaType) => Converters.Extension(mediaType);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
List<string> logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
if (File.Exists($"{basePath}.cicm.xml"))
|
||||
logFiles.Add($"{basePath}.cicm.xml");
|
||||
if (File.Exists($"{basePath}.ibg"))
|
||||
logFiles.Add($"{basePath}.ibg");
|
||||
if (File.Exists($"{basePath}.log"))
|
||||
logFiles.Add($"{basePath}.log");
|
||||
if (File.Exists($"{basePath}.mhddlog.bin"))
|
||||
logFiles.Add($"{basePath}.mhddlog.bin");
|
||||
if (File.Exists($"{basePath}.resume.xml"))
|
||||
logFiles.Add($"{basePath}.resume.xml");
|
||||
if (File.Exists($"{basePath}.sub.log"))
|
||||
logFiles.Add($"{basePath}.sub.log");
|
||||
|
||||
break;
|
||||
|
||||
case MediaType.DVD:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
if (File.Exists($"{basePath}.cicm.xml"))
|
||||
logFiles.Add($"{basePath}.cicm.xml");
|
||||
if (File.Exists($"{basePath}.ibg"))
|
||||
logFiles.Add($"{basePath}.ibg");
|
||||
if (File.Exists($"{basePath}.log"))
|
||||
logFiles.Add($"{basePath}.log");
|
||||
if (File.Exists($"{basePath}.mhddlog.bin"))
|
||||
logFiles.Add($"{basePath}.mhddlog.bin");
|
||||
if (File.Exists($"{basePath}.resume.xml"))
|
||||
logFiles.Add($"{basePath}.resume.xml");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsDumpingCommand()
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MPF.CleanRip
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive)
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts)
|
||||
{
|
||||
info.TracksAndWriteOffsets.ClrMameProData = GetCleanripDatfile(basePath + ".iso", basePath + "-dumpinfo.txt");
|
||||
|
||||
@@ -89,11 +89,34 @@ namespace MPF.CleanRip
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill in any artifacts that exist, Base64-encoded
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
info.Artifacts["bca"] = GetBase64(GetFullFile(basePath + ".bca", binary: true));
|
||||
if (File.Exists(basePath + "-dumpinfo.txt"))
|
||||
info.Artifacts["dumpinfo"] = GetBase64(GetFullFile(basePath + "-dumpinfo.txt"));
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
info.Artifacts["bca"] = GetBase64(GetFullFile(basePath + ".bca", binary: true));
|
||||
if (File.Exists(basePath + "-dumpinfo.txt"))
|
||||
info.Artifacts["dumpinfo"] = GetBase64(GetFullFile(basePath + "-dumpinfo.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
List<string> logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.DVD: // Only added here to help users; not strictly correct
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
if (File.Exists($"{basePath}-dumpinfo.txt"))
|
||||
logFiles.Add($"{basePath}-dumpinfo.txt");
|
||||
if (File.Exists($"{basePath}.bca"))
|
||||
logFiles.Add($"{basePath}.bca");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace MPF.DD
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive)
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts)
|
||||
{
|
||||
// TODO: Fill in submission info specifics for DD
|
||||
string outputDirectory = Path.GetDirectoryName(basePath);
|
||||
|
||||
@@ -123,7 +123,8 @@ namespace MPF.Data
|
||||
/// <param name="submissionInfo">Base submission info to fill in specifics for</param>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <param name="drive">Drive representing the disc to get information from</param>
|
||||
public abstract void GenerateSubmissionInfo(SubmissionInfo submissionInfo, string basePath, Drive drive);
|
||||
/// <param name="includeArtifacts">True to include output files as encoded artifacts, false otherwise</param>
|
||||
public abstract void GenerateSubmissionInfo(SubmissionInfo submissionInfo, string basePath, Drive drive, bool includeArtifacts);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -142,6 +143,13 @@ namespace MPF.Data
|
||||
/// <returns>String representing the media type, null on error</returns>
|
||||
public virtual string GetDefaultExtension(MediaType? mediaType) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of all log files generated
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>List of all log file paths, empty otherwise</returns>
|
||||
public virtual List<string> GetLogFilePaths(string basePath) => new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Get the MediaType from the current set of parameters
|
||||
/// </summary>
|
||||
|
||||
@@ -478,6 +478,17 @@ namespace MPF.Data
|
||||
resultProgress?.Report(Result.Failure("Writing could not complete!"));
|
||||
}
|
||||
|
||||
// Conpress the logs, if required
|
||||
if (Options.CompressLogFiles)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Compressing log files..."));
|
||||
success = CompressLogFiles();
|
||||
if (success)
|
||||
resultProgress?.Report(Result.Success("Compression complete!"));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure("Compression could not complete!"));
|
||||
}
|
||||
|
||||
resultProgress?.Report(Result.Success("Submission information process complete!"));
|
||||
return Result.Success();
|
||||
}
|
||||
@@ -597,7 +608,7 @@ namespace MPF.Data
|
||||
};
|
||||
|
||||
// Get specific tool output handling
|
||||
Parameters.GenerateSubmissionInfo(info, combinedBase, this.Drive);
|
||||
Parameters.GenerateSubmissionInfo(info, combinedBase, this.Drive, Options.OutputSubmissionJSON);
|
||||
|
||||
// Get a list of matching IDs for each line in the DAT
|
||||
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets.ClrMameProData) && Options.HasRedumpLogin)
|
||||
@@ -1292,6 +1303,51 @@ namespace MPF.Data
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress log files to save space
|
||||
/// </summary>
|
||||
/// <returns>True if the process succeeded, false otherwise</returns>
|
||||
private bool CompressLogFiles()
|
||||
{
|
||||
// Prepare the necessary paths
|
||||
string outputFilename = Path.GetFileNameWithoutExtension(OutputFilename);
|
||||
string combinedBase = Path.Combine(OutputDirectory, outputFilename);
|
||||
string archiveName = combinedBase + "_logs.zip";
|
||||
|
||||
// Get the list of log files from the parameters object
|
||||
var files = Parameters.GetLogFilePaths(combinedBase);
|
||||
if (!files.Any())
|
||||
return true;
|
||||
|
||||
// Add the log files to the archive and delete the uncompressed file after
|
||||
ZipArchive zf = null;
|
||||
try
|
||||
{
|
||||
zf = ZipFile.Open(archiveName, ZipArchiveMode.Create);
|
||||
foreach (string file in files)
|
||||
{
|
||||
string entryName = file.Substring(OutputDirectory.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
zf.CreateEntryFromFile(file, entryName);
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
zf?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Information Extraction
|
||||
|
||||
@@ -286,6 +286,15 @@ namespace MPF.Data
|
||||
set { _settings["OutputSubmissionJSON"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress output log files to reduce space
|
||||
/// </summary>
|
||||
public bool CompressLogFiles
|
||||
{
|
||||
get { return GetBooleanSetting(_settings, "CompressLogFiles", false); }
|
||||
set { _settings["CompressLogFiles"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skip Options
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace MPF.DiscImageCreator
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive)
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts)
|
||||
{
|
||||
string outputDirectory = Path.GetDirectoryName(basePath);
|
||||
|
||||
@@ -708,53 +708,56 @@ namespace MPF.DiscImageCreator
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill in any artifacts that exist, Base64-encoded
|
||||
//if (File.Exists(basePath + ".c2"))
|
||||
// info.Artifacts["c2"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".c2"));
|
||||
if (File.Exists(basePath + "_c2Error.txt"))
|
||||
info.Artifacts["c2Error"] = GetBase64(GetFullFile(basePath + "_c2Error.txt"));
|
||||
if (File.Exists(basePath + ".ccd"))
|
||||
info.Artifacts["ccd"] = GetBase64(GetFullFile(basePath + ".ccd"));
|
||||
if (File.Exists(basePath + "_cmd.txt")) // TODO: Figure out how to read in the timestamp-named file
|
||||
info.Artifacts["cmd"] = GetBase64(GetFullFile(basePath + "_cmd.txt"));
|
||||
if (File.Exists(basePath + ".cue"))
|
||||
info.Artifacts["cue"] = GetBase64(GetFullFile(basePath + ".cue"));
|
||||
if (File.Exists(basePath + ".dat"))
|
||||
info.Artifacts["dat"] = GetBase64(GetFullFile(basePath + ".dat"));
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt"));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "DMI.bin")))
|
||||
// info.Artifacts["dmi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "DMI.bin")));
|
||||
if (File.Exists(basePath + "_drive.txt"))
|
||||
info.Artifacts["drive"] = GetBase64(GetFullFile(basePath + "_drive.txt"));
|
||||
if (File.Exists(basePath + "_img.cue"))
|
||||
info.Artifacts["img_cue"] = GetBase64(GetFullFile(basePath + "_img.cue"));
|
||||
if (File.Exists(basePath + ".img_EdcEcc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = GetBase64(GetFullFile(basePath + ".img_EdcEcc.txt"));
|
||||
if (File.Exists(basePath + ".img_EccEdc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = GetBase64(GetFullFile(basePath + ".img_EccEdc.txt"));
|
||||
if (File.Exists(basePath + "_mainError.txt"))
|
||||
info.Artifacts["mainError"] = GetBase64(GetFullFile(basePath + "_mainError.txt"));
|
||||
if (File.Exists(basePath + "_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = GetBase64(GetFullFile(basePath + "_mainInfo.txt"));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "PFI.bin")))
|
||||
// info.Artifacts["pfi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "PFI.bin")));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "SS.bin")))
|
||||
// info.Artifacts["ss"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "SS.bin")));
|
||||
if (File.Exists(basePath + ".sub"))
|
||||
info.Artifacts["sub"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".sub"));
|
||||
if (File.Exists(basePath + "_subError.txt"))
|
||||
info.Artifacts["subError"] = GetBase64(GetFullFile(basePath + "_subError.txt"));
|
||||
if (File.Exists(basePath + "_subInfo.txt"))
|
||||
info.Artifacts["subInfo"] = GetBase64(GetFullFile(basePath + "_subInfo.txt"));
|
||||
if (File.Exists(basePath + "_subIntention.txt"))
|
||||
info.Artifacts["subIntention"] = GetBase64(GetFullFile(basePath + "_subIntention.txt"));
|
||||
//if (File.Exists(basePath + "_sub.txt"))
|
||||
// info.Artifacts["subReadable"] = GetBase64(GetFullFile(basePath + "_sub.txt"));
|
||||
//if (File.Exists(basePath + "_subReadable.txt"))
|
||||
// info.Artifacts["subReadable"] = GetBase64(GetFullFile(basePath + "_subReadable.txt"));
|
||||
if (File.Exists(basePath + "_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = GetBase64(GetFullFile(basePath + "_volDesc.txt"));
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
//if (File.Exists(basePath + ".c2"))
|
||||
// info.Artifacts["c2"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".c2"));
|
||||
if (File.Exists(basePath + "_c2Error.txt"))
|
||||
info.Artifacts["c2Error"] = GetBase64(GetFullFile(basePath + "_c2Error.txt"));
|
||||
if (File.Exists(basePath + ".ccd"))
|
||||
info.Artifacts["ccd"] = GetBase64(GetFullFile(basePath + ".ccd"));
|
||||
if (File.Exists(basePath + "_cmd.txt")) // TODO: Figure out how to read in the timestamp-named file
|
||||
info.Artifacts["cmd"] = GetBase64(GetFullFile(basePath + "_cmd.txt"));
|
||||
if (File.Exists(basePath + ".cue"))
|
||||
info.Artifacts["cue"] = GetBase64(GetFullFile(basePath + ".cue"));
|
||||
if (File.Exists(basePath + ".dat"))
|
||||
info.Artifacts["dat"] = GetBase64(GetFullFile(basePath + ".dat"));
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt"));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "DMI.bin")))
|
||||
// info.Artifacts["dmi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "DMI.bin")));
|
||||
if (File.Exists(basePath + "_drive.txt"))
|
||||
info.Artifacts["drive"] = GetBase64(GetFullFile(basePath + "_drive.txt"));
|
||||
if (File.Exists(basePath + "_img.cue"))
|
||||
info.Artifacts["img_cue"] = GetBase64(GetFullFile(basePath + "_img.cue"));
|
||||
if (File.Exists(basePath + ".img_EdcEcc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = GetBase64(GetFullFile(basePath + ".img_EdcEcc.txt"));
|
||||
if (File.Exists(basePath + ".img_EccEdc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = GetBase64(GetFullFile(basePath + ".img_EccEdc.txt"));
|
||||
if (File.Exists(basePath + "_mainError.txt"))
|
||||
info.Artifacts["mainError"] = GetBase64(GetFullFile(basePath + "_mainError.txt"));
|
||||
if (File.Exists(basePath + "_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = GetBase64(GetFullFile(basePath + "_mainInfo.txt"));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "PFI.bin")))
|
||||
// info.Artifacts["pfi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "PFI.bin")));
|
||||
//if (File.Exists(Path.Combine(outputDirectory, "SS.bin")))
|
||||
// info.Artifacts["ss"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, "SS.bin")));
|
||||
if (File.Exists(basePath + ".sub"))
|
||||
info.Artifacts["sub"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".sub"));
|
||||
if (File.Exists(basePath + "_subError.txt"))
|
||||
info.Artifacts["subError"] = GetBase64(GetFullFile(basePath + "_subError.txt"));
|
||||
if (File.Exists(basePath + "_subInfo.txt"))
|
||||
info.Artifacts["subInfo"] = GetBase64(GetFullFile(basePath + "_subInfo.txt"));
|
||||
if (File.Exists(basePath + "_subIntention.txt"))
|
||||
info.Artifacts["subIntention"] = GetBase64(GetFullFile(basePath + "_subIntention.txt"));
|
||||
//if (File.Exists(basePath + "_sub.txt"))
|
||||
// info.Artifacts["subReadable"] = GetBase64(GetFullFile(basePath + "_sub.txt"));
|
||||
//if (File.Exists(basePath + "_subReadable.txt"))
|
||||
// info.Artifacts["subReadable"] = GetBase64(GetFullFile(basePath + "_subReadable.txt"));
|
||||
if (File.Exists(basePath + "_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = GetBase64(GetFullFile(basePath + "_volDesc.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -1216,6 +1219,109 @@ namespace MPF.DiscImageCreator
|
||||
/// <inheritdoc/>
|
||||
public override string GetDefaultExtension(MediaType? mediaType) => Converters.Extension(mediaType);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
var currentFiles = Directory.GetFiles(Path.GetDirectoryName(basePath));
|
||||
string cmdPath = currentFiles.FirstOrDefault(f => Regex.IsMatch(f, @"\d{8}T\d{6}"));
|
||||
|
||||
List<string> logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM: // TODO: Verify GD-ROM outputs this
|
||||
if (File.Exists($"{basePath}.c2"))
|
||||
logFiles.Add($"{basePath}.c2");
|
||||
if (File.Exists($"{basePath}_c2Error.txt"))
|
||||
logFiles.Add($"{basePath}_c2Error.txt");
|
||||
if (File.Exists($"{basePath}.ccd"))
|
||||
logFiles.Add($"{basePath}.ccd");
|
||||
if (cmdPath != null && File.Exists(cmdPath))
|
||||
logFiles.Add(cmdPath);
|
||||
if (File.Exists($"{basePath}_cmd.txt"))
|
||||
logFiles.Add($"{basePath}_cmd.txt");
|
||||
if (File.Exists($"{basePath}.dat"))
|
||||
logFiles.Add($"{basePath}.dat");
|
||||
if (File.Exists($"{basePath}.sub"))
|
||||
logFiles.Add($"{basePath}.sub");
|
||||
if (File.Exists($"{basePath}.subtmp"))
|
||||
logFiles.Add($"{basePath}.subtmp");
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
logFiles.Add($"{basePath}_disc.txt");
|
||||
if (File.Exists($"{basePath}_drive.txt"))
|
||||
logFiles.Add($"{basePath}_drive.txt");
|
||||
if (File.Exists($"{basePath}_img.cue"))
|
||||
logFiles.Add($"{basePath}_img.cue");
|
||||
if (File.Exists($"{basePath}_mainError.txt"))
|
||||
logFiles.Add($"{basePath}_mainError.txt");
|
||||
if (File.Exists($"{basePath}_mainInfo.txt"))
|
||||
logFiles.Add($"{basePath}_mainInfo.txt");
|
||||
if (File.Exists($"{basePath}_sub.txt"))
|
||||
logFiles.Add($"{basePath}_sub.txt");
|
||||
if (File.Exists($"{basePath}_subError.txt"))
|
||||
logFiles.Add($"{basePath}_subError.txt");
|
||||
if (File.Exists($"{basePath}_subInfo.txt"))
|
||||
logFiles.Add($"{basePath}_subInfo.txt");
|
||||
if (File.Exists($"{basePath}_subIntention.txt"))
|
||||
logFiles.Add($"{basePath}_subIntention.txt");
|
||||
if (File.Exists($"{basePath}_subReadable.txt"))
|
||||
logFiles.Add($"{basePath}_subReadable.txt");
|
||||
if (File.Exists($"{basePath}_volDesc.txt"))
|
||||
logFiles.Add($"{basePath}_volDesc.txt");
|
||||
|
||||
// Audio-only discs don't output these files
|
||||
if (!this.System.IsAudio())
|
||||
{
|
||||
if (File.Exists($"{basePath}.img_EdcEcc.txt"))
|
||||
logFiles.Add($"{basePath}.img_EdcEcc.txt");
|
||||
if (File.Exists($"{basePath}.img_EccEdc.txt"))
|
||||
logFiles.Add($"{basePath}.img_EccEdc.txt");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MediaType.DVD:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
if (cmdPath != null && File.Exists(cmdPath))
|
||||
logFiles.Add(cmdPath);
|
||||
if (File.Exists($"{basePath}_cmd.txt"))
|
||||
logFiles.Add($"{basePath}_cmd.txt");
|
||||
if (File.Exists($"{basePath}.dat"))
|
||||
logFiles.Add($"{basePath}.dat");
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
logFiles.Add($"{basePath}_disc.txt");
|
||||
if (File.Exists($"{basePath}_drive.txt"))
|
||||
logFiles.Add($"{basePath}_drive.txt");
|
||||
if (File.Exists($"{basePath}_mainError.txt"))
|
||||
logFiles.Add($"{basePath}_mainError.txt");
|
||||
if (File.Exists($"{basePath}_mainInfo.txt"))
|
||||
logFiles.Add($"{basePath}_mainInfo.txt");
|
||||
if (File.Exists($"{basePath}_volDesc.txt"))
|
||||
logFiles.Add($"{basePath}_volDesc.txt");
|
||||
|
||||
break;
|
||||
|
||||
case MediaType.FloppyDisk:
|
||||
case MediaType.HardDisk:
|
||||
// TODO: Determine what outputs come out from a HDD, SD, etc.
|
||||
if (cmdPath != null && File.Exists(cmdPath))
|
||||
logFiles.Add(cmdPath);
|
||||
if (File.Exists($"{basePath}_cmd.txt"))
|
||||
logFiles.Add($"{basePath}_cmd.txt");
|
||||
if (File.Exists($"{basePath}.dat"))
|
||||
logFiles.Add($"{basePath}.dat");
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
logFiles.Add($"{basePath}_disc.txt");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? GetMediaType() => Converters.ToMediaType(BaseCommand);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="System.Management" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace MPF.UmdImageCreator
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive)
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts)
|
||||
{
|
||||
// Extract info based generically on MediaType
|
||||
switch (this.Type)
|
||||
@@ -86,15 +86,40 @@ namespace MPF.UmdImageCreator
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill in any artifacts that exist, Base64-encoded
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt"));
|
||||
if (File.Exists(basePath + "_mainError.txt"))
|
||||
info.Artifacts["mainError"] = GetBase64(GetFullFile(basePath + "_mainError.txt"));
|
||||
if (File.Exists(basePath + "_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = GetBase64(GetFullFile(basePath + "_mainInfo.txt"));
|
||||
if (File.Exists(basePath + "_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = GetBase64(GetFullFile(basePath + "_volDesc.txt"));
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt"));
|
||||
if (File.Exists(basePath + "_mainError.txt"))
|
||||
info.Artifacts["mainError"] = GetBase64(GetFullFile(basePath + "_mainError.txt"));
|
||||
if (File.Exists(basePath + "_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = GetBase64(GetFullFile(basePath + "_mainInfo.txt"));
|
||||
if (File.Exists(basePath + "_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = GetBase64(GetFullFile(basePath + "_volDesc.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
List<string> logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.UMD:
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
logFiles.Add($"{basePath}_disc.txt");
|
||||
if (File.Exists($"{basePath}_mainError.txt"))
|
||||
logFiles.Add($"{basePath}_mainError.txt");
|
||||
if (File.Exists($"{basePath}_mainInfo.txt"))
|
||||
logFiles.Add($"{basePath}_mainInfo.txt");
|
||||
if (File.Exists($"{basePath}_volDesc.txt"))
|
||||
logFiles.Add($"{basePath}_volDesc.txt");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return logFiles;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -109,6 +109,11 @@
|
||||
IsChecked="{Binding Path=UIOptions.Options.OutputSubmissionJSON}"
|
||||
ToolTip="Enable outputting a compressed JSON version of the submission info" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Compress Log Files"
|
||||
IsChecked="{Binding Path=UIOptions.Options.CompressLogFiles}"
|
||||
ToolTip="Compress output log files to reduce space" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user