Extension cleanup

This commit is contained in:
Matt Nadareski
2020-12-30 14:28:46 -08:00
parent f27040cd1c
commit a3e6f8157f
2 changed files with 53 additions and 31 deletions

View File

@@ -1687,12 +1687,6 @@ namespace MPF.DiscImageCreator
/// <returns></returns>
public override bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type, IProgress<Result> progress = null)
{
// Some disc types are audio-only
bool audioOnly = (system == KnownSystem.AtariJaguarCD)
|| (system == KnownSystem.AudioCD)
|| (system == KnownSystem.DVDAudio)
|| (system == KnownSystem.SuperAudioCD);
/*
If there are no external programs, such as error checking, etc., DIC outputs
a slightly different set of files. This reduced set needs to be documented in
@@ -1750,7 +1744,7 @@ namespace MPF.DiscImageCreator
missingFiles += $";{basePath}_volDesc.txt";
// Audio-only discs don't output these files
if (!audioOnly)
if (!system.IsAudio())
{
if (!File.Exists($"{basePath}.img_EdcEcc.txt") && !File.Exists($"{basePath}.img_EccEdc.txt"))
missingFiles += $";{basePath}.img_EdcEcc.txt";
@@ -1856,12 +1850,6 @@ namespace MPF.DiscImageCreator
{
string outputDirectory = Path.GetDirectoryName(basePath);
// Some disc types are audio-only
bool audioOnly = (system == KnownSystem.AtariJaguarCD)
|| (system == KnownSystem.AudioCD)
|| (system == KnownSystem.DVDAudio)
|| (system == KnownSystem.SuperAudioCD);
// Fill in the hash data
info.TracksAndWriteOffsets.ClrMameProData = GetDatfile(basePath + ".dat");
@@ -1873,7 +1861,7 @@ namespace MPF.DiscImageCreator
info.Extras.PVD = GetPVD(basePath + "_mainInfo.txt") ?? "Disc has no PVD"; ;
// Audio-only discs will fail if there are any C2 errors, so they would never get here
if (audioOnly)
if (system.IsAudio())
{
info.CommonDiscInfo.ErrorsCount = "0";
}

View File

@@ -4,23 +4,11 @@ namespace MPF.Utilities
{
public static class Extensions
{
public static bool DoesSupportDriveSpeed(this MediaType? type)
{
switch (type)
{
case MediaType.CDROM:
case MediaType.DVD:
case MediaType.GDROM:
case MediaType.HDDVD:
case MediaType.BluRay:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
return true;
default:
return false;
}
}
/// <summary>
/// Determine the category based on the system
/// </summary>
/// <param name="system">KnownSystem value to check</param>
/// <returns>KnownSystemCategory related to the system</returns>
public static KnownSystemCategory Category(this KnownSystem? system)
{
if (system < KnownSystem.MarkerDiscBasedConsoleEnd)
@@ -39,6 +27,52 @@ namespace MPF.Utilities
return KnownSystemCategory.Custom;
}
/// <summary>
/// Determine if the media supports drive speeds
/// </summary>
/// <param name="type">MediaType value to check</param>
/// <returns>True if the media has variable dumping speeds, false otherwise</returns>
public static bool DoesSupportDriveSpeed(this MediaType? type)
{
switch (type)
{
case MediaType.CDROM:
case MediaType.DVD:
case MediaType.GDROM:
case MediaType.HDDVD:
case MediaType.BluRay:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
return true;
default:
return false;
}
}
/// <summary>
/// Determine if a system is considered audio-only
/// </summary>
/// <param name="system">KnownSystem value to check</param>
/// <returns>True if the system is audio-only, false otherwise</returns>
public static bool IsAudio(this KnownSystem? system)
{
switch (system)
{
case KnownSystem.AtariJaguarCD:
case KnownSystem.AudioCD:
case KnownSystem.DVDAudio:
case KnownSystem.SuperAudioCD:
return true;
default:
return false;
}
}
/// <summary>
/// Determine if a system is a marker value
/// </summary>
/// <param name="system">KnownSystem value to check</param>
/// <returns>True if the system is a marker value, false otherwise</returns>
public static bool IsMarker(this KnownSystem? system)
{
switch (system)