mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Support C# 12 syntax
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
- Fix BE flag logic bug in DIC
|
||||
- Support ancient .NET in Core
|
||||
- Support ancient .NET in UI Core
|
||||
- Support C# 12 syntax
|
||||
|
||||
### 3.0.0 (2023-11-14)
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace MPF.Core.Data
|
||||
|
||||
// Sanitize a Windows-formatted long device path
|
||||
if (devicePath.StartsWith("\\\\.\\"))
|
||||
devicePath = devicePath.Substring("\\\\.\\".Length);
|
||||
devicePath = devicePath["\\\\.\\".Length..];
|
||||
|
||||
// Create and validate the drive info object
|
||||
var driveInfo = new DriveInfo(devicePath);
|
||||
@@ -161,7 +161,7 @@ namespace MPF.Core.Data
|
||||
public static List<Drive> CreateListOfDrives(bool ignoreFixedDrives)
|
||||
{
|
||||
var drives = GetDriveList(ignoreFixedDrives);
|
||||
drives = drives.OrderBy(i => i == null ? "\0" : i.Name).ToList();
|
||||
drives = [.. drives.OrderBy(i => i == null ? "\0" : i.Name)];
|
||||
return drives;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ namespace MPF.Core.Data
|
||||
{
|
||||
public class IniFile : IDictionary<string, string>
|
||||
{
|
||||
private Dictionary<string, string> _keyValuePairs = new();
|
||||
private Dictionary<string, string> _keyValuePairs = [];
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
_keyValuePairs ??= new Dictionary<string, string>();
|
||||
_keyValuePairs ??= [];
|
||||
|
||||
key = key.ToLowerInvariant();
|
||||
if (_keyValuePairs.ContainsKey(key))
|
||||
@@ -24,7 +24,7 @@ namespace MPF.Core.Data
|
||||
}
|
||||
set
|
||||
{
|
||||
_keyValuePairs ??= new Dictionary<string, string>();
|
||||
_keyValuePairs ??= [];
|
||||
|
||||
key = key.ToLowerInvariant();
|
||||
_keyValuePairs[key] = value;
|
||||
|
||||
@@ -289,11 +289,7 @@ namespace MPF.Core.Hashing
|
||||
/// <remarks>NonCryptographicHashAlgorithm implementations do not need finalization</remarks>
|
||||
public void Terminate()
|
||||
{
|
||||
#if NET40 || NET452
|
||||
byte[] emptyBuffer = [];
|
||||
#else
|
||||
byte[] emptyBuffer = Array.Empty<byte>();
|
||||
#endif
|
||||
switch (_hasher)
|
||||
{
|
||||
case HashAlgorithm ha:
|
||||
|
||||
@@ -1134,7 +1134,7 @@ namespace MPF.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
string entryName = file.Substring(outputDirectory!.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
string entryName = file[outputDirectory!.Length..].TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
|
||||
#if NETFRAMEWORK || NETCOREAPP3_1 || NET5_0
|
||||
zf.CreateEntryFromFile(file, entryName, CompressionLevel.Optimal);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.0</VersionPrefix>
|
||||
|
||||
@@ -33,6 +34,10 @@
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net4`))">
|
||||
<PackageReference Include="IndexRange" Version="1.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
info.Artifacts ??= new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
if (File.Exists(basePath + ".cicm.xml"))
|
||||
info.Artifacts["cicm"] = GetBase64(GetFullFile(basePath + ".cicm.xml")) ?? string.Empty;
|
||||
if (File.Exists(basePath + ".ibg"))
|
||||
@@ -1128,48 +1128,42 @@ namespace MPF.Core.Modules.Aaru
|
||||
{
|
||||
#region Archive Family
|
||||
|
||||
[CommandStrings.ArchivePrefixLong + " " + CommandStrings.ArchiveInfo] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ArchivePrefixLong + " " + CommandStrings.ArchiveInfo] = [],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Database Family
|
||||
|
||||
[CommandStrings.DatabasePrefixLong + " " + CommandStrings.DatabaseStats] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.DatabasePrefixLong + " " + CommandStrings.DatabaseStats] = [],
|
||||
|
||||
[CommandStrings.DatabasePrefixLong + " " + CommandStrings.DatabaseUpdate] = new List<string>()
|
||||
{
|
||||
[CommandStrings.DatabasePrefixLong + " " + CommandStrings.DatabaseUpdate] =
|
||||
[
|
||||
FlagStrings.ClearLong,
|
||||
FlagStrings.ClearAllLong,
|
||||
},
|
||||
],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Device Family
|
||||
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceInfo] = new List<string>()
|
||||
{
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceInfo] =
|
||||
[
|
||||
FlagStrings.OutputPrefixLong,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceList] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceList] = [],
|
||||
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceReport] = new List<string>()
|
||||
{
|
||||
[CommandStrings.DevicePrefixLong + " " + CommandStrings.DeviceReport] =
|
||||
[
|
||||
FlagStrings.TrapDiscLong,
|
||||
},
|
||||
],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filesystem Family
|
||||
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemExtract] = new List<string>()
|
||||
{
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemExtract] =
|
||||
[
|
||||
FlagStrings.EncodingLong,
|
||||
FlagStrings.EncodingShort,
|
||||
FlagStrings.ExtendedAttributesLong,
|
||||
@@ -1178,10 +1172,10 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.NamespaceShort,
|
||||
FlagStrings.OptionsLong,
|
||||
FlagStrings.OptionsShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemInfo] = new List<string>()
|
||||
{
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemInfo] =
|
||||
[
|
||||
FlagStrings.EncodingLong,
|
||||
FlagStrings.EncodingShort,
|
||||
FlagStrings.ExtendedAttributesLong,
|
||||
@@ -1190,10 +1184,10 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.NamespaceShort,
|
||||
FlagStrings.OptionsLong,
|
||||
FlagStrings.OptionsShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemListLong] = new List<string>()
|
||||
{
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemListLong] =
|
||||
[
|
||||
FlagStrings.EncodingLong,
|
||||
FlagStrings.EncodingShort,
|
||||
FlagStrings.FilesystemsLong,
|
||||
@@ -1202,18 +1196,16 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.LongFormatShort,
|
||||
FlagStrings.PartitionsLong,
|
||||
FlagStrings.PartitionsShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemOptions] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.FilesystemPrefixLong + " " + CommandStrings.FilesystemOptions] = [],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image Family
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageChecksumLong] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageChecksumLong] =
|
||||
[
|
||||
FlagStrings.Adler32Long,
|
||||
FlagStrings.Adler32Short,
|
||||
FlagStrings.CRC16Long,
|
||||
@@ -1235,14 +1227,12 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.SpamSumShort,
|
||||
FlagStrings.WholeDiscLong,
|
||||
FlagStrings.WholeDiscShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageCompareLong] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageCompareLong] = [],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageConvert] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageConvert] =
|
||||
[
|
||||
FlagStrings.CommentsLong,
|
||||
FlagStrings.CountLong,
|
||||
FlagStrings.CountShort,
|
||||
@@ -1275,20 +1265,20 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.ResumeFileShort,
|
||||
FlagStrings.XMLSidecarLong,
|
||||
FlagStrings.XMLSidecarShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageCreateSidecar] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageCreateSidecar] =
|
||||
[
|
||||
FlagStrings.BlockSizeLong,
|
||||
FlagStrings.BlockSizeShort,
|
||||
FlagStrings.EncodingLong,
|
||||
FlagStrings.EncodingShort,
|
||||
FlagStrings.TapeLong,
|
||||
FlagStrings.TapeShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageDecode] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageDecode] =
|
||||
[
|
||||
FlagStrings.DiskTagsLong,
|
||||
FlagStrings.DiskTagsShort,
|
||||
FlagStrings.LengthLong,
|
||||
@@ -1297,28 +1287,24 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.SectorTagsShort,
|
||||
FlagStrings.StartLong,
|
||||
FlagStrings.StartShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageEntropy] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageEntropy] =
|
||||
[
|
||||
FlagStrings.DuplicatedSectorsLong,
|
||||
FlagStrings.DuplicatedSectorsShort,
|
||||
FlagStrings.SeparatedTracksLong,
|
||||
FlagStrings.SeparatedTracksShort,
|
||||
FlagStrings.WholeDiscLong,
|
||||
FlagStrings.WholeDiscShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageInfo] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageInfo] = [],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageOptions] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageOptions] = [],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImagePrint] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImagePrint] =
|
||||
[
|
||||
FlagStrings.LengthLong,
|
||||
FlagStrings.LengthShort,
|
||||
FlagStrings.LongSectorsLong,
|
||||
@@ -1327,22 +1313,22 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.StartShort,
|
||||
FlagStrings.WidthLong,
|
||||
FlagStrings.WidthShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageVerify] = new List<string>()
|
||||
{
|
||||
[CommandStrings.ImagePrefixLong + " " + CommandStrings.ImageVerify] =
|
||||
[
|
||||
FlagStrings.VerifyDiscLong,
|
||||
FlagStrings.VerifyDiscShort,
|
||||
FlagStrings.VerifySectorsLong,
|
||||
FlagStrings.VerifySectorsShort,
|
||||
},
|
||||
],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Media Family
|
||||
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaDump] = new List<string>()
|
||||
{
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaDump] =
|
||||
[
|
||||
FlagStrings.EjectLong,
|
||||
FlagStrings.EncodingLong,
|
||||
FlagStrings.EncodingShort,
|
||||
@@ -1380,29 +1366,29 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.UseBufferedReadsLong,
|
||||
FlagStrings.XMLSidecarLong,
|
||||
FlagStrings.XMLSidecarShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaInfo] = new List<string>()
|
||||
{
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaInfo] =
|
||||
[
|
||||
FlagStrings.OutputPrefixLong,
|
||||
FlagStrings.OutputPrefixShort,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaScan] = new List<string>()
|
||||
{
|
||||
[CommandStrings.MediaPrefixLong + " " + CommandStrings.MediaScan] =
|
||||
[
|
||||
FlagStrings.ImgBurnLogLong,
|
||||
FlagStrings.ImgBurnLogShort,
|
||||
FlagStrings.MHDDLogLong,
|
||||
FlagStrings.MHDDLogShort,
|
||||
FlagStrings.UseBufferedReadsLong,
|
||||
},
|
||||
],
|
||||
|
||||
#endregion
|
||||
|
||||
#region Standalone Commands
|
||||
|
||||
[CommandStrings.NONE] = new List<string>()
|
||||
{
|
||||
[CommandStrings.NONE] =
|
||||
[
|
||||
FlagStrings.DebugLong,
|
||||
FlagStrings.DebugShort,
|
||||
FlagStrings.HelpLong,
|
||||
@@ -1411,27 +1397,17 @@ namespace MPF.Core.Modules.Aaru
|
||||
FlagStrings.VerboseLong,
|
||||
FlagStrings.VerboseShort,
|
||||
FlagStrings.VersionLong,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Configure] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Configure] = [],
|
||||
|
||||
[CommandStrings.Formats] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Formats] = [],
|
||||
|
||||
[CommandStrings.ListEncodings] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ListEncodings] = [],
|
||||
|
||||
[CommandStrings.ListNamespaces] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.ListNamespaces] = [],
|
||||
|
||||
[CommandStrings.Remote] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Remote] = [],
|
||||
|
||||
#endregion
|
||||
};
|
||||
@@ -1500,7 +1476,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
{
|
||||
BaseCommand = CommandStrings.NONE;
|
||||
|
||||
flags = new Dictionary<string, bool?>();
|
||||
flags = [];
|
||||
|
||||
BlockSizeValue = null;
|
||||
CommentsValue = null;
|
||||
@@ -2470,14 +2446,14 @@ namespace MPF.Core.Modules.Aaru
|
||||
}
|
||||
}
|
||||
|
||||
cueTrack.Indices = cueIndicies.ToArray();
|
||||
cueTrack.Indices = [.. cueIndicies];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default if index data missing from sidecar
|
||||
cueTrack.Indices = new CueIndex[]
|
||||
{
|
||||
new CueIndex
|
||||
new()
|
||||
{
|
||||
Index = 1,
|
||||
Minutes = 0,
|
||||
@@ -2496,7 +2472,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
}
|
||||
|
||||
// If we have a cuesheet to write out, do so
|
||||
cueSheet.Files = cueFiles.ToArray();
|
||||
cueSheet.Files = [.. cueFiles];
|
||||
if (cueSheet != null && cueSheet != default)
|
||||
{
|
||||
var ms = new SabreTools.Serialization.Streams.CueSheet().Serialize(cueSheet);
|
||||
@@ -2726,7 +2702,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
|
||||
// Assign the roms to a new game
|
||||
datafile.Games = new Game[1];
|
||||
datafile.Games[0] = new Game { Roms = roms.ToArray() };
|
||||
datafile.Games[0] = new Game { Roms = [.. roms] };
|
||||
|
||||
return datafile;
|
||||
}
|
||||
@@ -2887,7 +2863,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
pvdData.AddRange(new string((char)0, 14).ToCharArray().Select(c => (byte)c));
|
||||
|
||||
// Return the filled array
|
||||
return pvdData.ToArray();
|
||||
return [.. pvdData];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2928,7 +2904,7 @@ namespace MPF.Core.Modules.Aaru
|
||||
// Get and return the byte array
|
||||
List<byte> dateTimeList = dateTimeString.ToCharArray().Select(c => (byte)c).ToList();
|
||||
dateTimeList.Add(timeZoneNumber);
|
||||
return dateTimeList.ToArray();
|
||||
return [.. dateTimeList];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace MPF.Core.Modules
|
||||
/// <summary>
|
||||
/// Set of flags to pass to the executable
|
||||
/// </summary>
|
||||
protected Dictionary<string, bool?> flags = new();
|
||||
protected Dictionary<string, bool?> flags = [];
|
||||
protected internal IEnumerable<string> Keys => flags.Keys;
|
||||
|
||||
/// <summary>
|
||||
@@ -1120,7 +1120,7 @@ namespace MPF.Core.Modules
|
||||
return null;
|
||||
|
||||
if (trimLength > -1)
|
||||
hex = hex.Substring(0, trimLength);
|
||||
hex = hex[..trimLength];
|
||||
|
||||
return Regex.Replace(hex, ".{32}", "$0\n", RegexOptions.Compiled);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace MPF.Core.Modules.CleanRip
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
info.Artifacts ??= new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
info.Artifacts["bca"] = GetBase64(GetFullFile(basePath + ".bca", binary: true)) ?? string.Empty;
|
||||
@@ -171,25 +171,25 @@ namespace MPF.Core.Modules.CleanRip
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
else if (line!.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
crc = line[7..].ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
md5 = line[5..];
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
sha1 = line[7..];
|
||||
}
|
||||
|
||||
return new Datafile
|
||||
{
|
||||
Games = new Game[]
|
||||
{
|
||||
new Game
|
||||
Games =
|
||||
[
|
||||
new()
|
||||
{
|
||||
Roms = new Rom[]
|
||||
{
|
||||
Roms =
|
||||
[
|
||||
new Rom { Name = Path.GetFileName(iso), Size = size.ToString(), Crc = crc, Md5 = md5, Sha1 = sha1 },
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
catch
|
||||
@@ -257,11 +257,11 @@ namespace MPF.Core.Modules.CleanRip
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
else if (line!.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
crc = line[7..].ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
md5 = line[5..];
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
sha1 = line[7..];
|
||||
}
|
||||
|
||||
return $"<rom name=\"{Path.GetFileName(iso)}\" size=\"{size}\" crc=\"{crc}\" md5=\"{md5}\" sha1=\"{sha1}\" />";
|
||||
@@ -306,15 +306,15 @@ namespace MPF.Core.Modules.CleanRip
|
||||
}
|
||||
else if (line!.StartsWith("Version"))
|
||||
{
|
||||
version = line.Substring("Version: ".Length);
|
||||
version = line["Version: ".Length..];
|
||||
}
|
||||
else if (line.StartsWith("Internal Name"))
|
||||
{
|
||||
name = line.Substring("Internal Name: ".Length);
|
||||
name = line["Internal Name: ".Length..];
|
||||
}
|
||||
else if (line.StartsWith("Filename"))
|
||||
{
|
||||
string serial = line.Substring("Filename: ".Length);
|
||||
string serial = line["Filename: ".Length..];
|
||||
|
||||
// char gameType = serial[0];
|
||||
// string gameid = serial[1] + serial[2];
|
||||
|
||||
@@ -825,7 +825,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
info.Artifacts ??= new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
//if (File.Exists($"{basePath}.c2"))
|
||||
// info.Artifacts["c2"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}.c2")) ?? string.Empty;
|
||||
@@ -1368,8 +1368,8 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
{
|
||||
return new Dictionary<string, List<string>>()
|
||||
{
|
||||
[CommandStrings.Audio] = new List<string>()
|
||||
{
|
||||
[CommandStrings.Audio] =
|
||||
[
|
||||
FlagStrings.BEOpcode,
|
||||
FlagStrings.C2Opcode,
|
||||
FlagStrings.D8Opcode,
|
||||
@@ -1385,23 +1385,21 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.ScanSectorProtect,
|
||||
FlagStrings.SkipSector,
|
||||
FlagStrings.SubchannelReadLevel,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.BluRay] = new List<string>()
|
||||
{
|
||||
[CommandStrings.BluRay] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
FlagStrings.DVDReread,
|
||||
FlagStrings.ForceUnitAccess,
|
||||
FlagStrings.UseAnchorVolumeDescriptorPointer,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Close] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Close] = [],
|
||||
|
||||
[CommandStrings.CompactDisc] = new List<string>()
|
||||
{
|
||||
[CommandStrings.CompactDisc] =
|
||||
[
|
||||
FlagStrings.AddOffset,
|
||||
FlagStrings.AMSF,
|
||||
FlagStrings.AtariJaguar,
|
||||
@@ -1426,10 +1424,10 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.VideoNow,
|
||||
FlagStrings.VideoNowColor,
|
||||
FlagStrings.VideoNowXP,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Data] = new List<string>()
|
||||
{
|
||||
[CommandStrings.Data] =
|
||||
[
|
||||
FlagStrings.BEOpcode,
|
||||
FlagStrings.C2Opcode,
|
||||
FlagStrings.D8Opcode,
|
||||
@@ -1445,10 +1443,10 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.ScanSectorProtect,
|
||||
FlagStrings.SkipSector,
|
||||
FlagStrings.SubchannelReadLevel,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.DigitalVideoDisc] = new List<string>()
|
||||
{
|
||||
[CommandStrings.DigitalVideoDisc] =
|
||||
[
|
||||
FlagStrings.CopyrightManagementInformation,
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
@@ -1463,28 +1461,24 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.ScanFileProtect,
|
||||
FlagStrings.SkipSector,
|
||||
FlagStrings.UseAnchorVolumeDescriptorPointer,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Disk] = new List<string>()
|
||||
{
|
||||
[CommandStrings.Disk] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.DriveSpeed] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.DriveSpeed] = [],
|
||||
|
||||
[CommandStrings.Eject] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Eject] = [],
|
||||
|
||||
[CommandStrings.Floppy] = new List<string>()
|
||||
{
|
||||
[CommandStrings.Floppy] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.GDROM] = new List<string>()
|
||||
{
|
||||
[CommandStrings.GDROM] =
|
||||
[
|
||||
FlagStrings.BEOpcode,
|
||||
FlagStrings.C2Opcode,
|
||||
FlagStrings.D8Opcode,
|
||||
@@ -1495,40 +1489,28 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.NoFixSubQ,
|
||||
FlagStrings.NoFixSubRtoW,
|
||||
FlagStrings.SubchannelReadLevel,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.MDS] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.MDS] = [],
|
||||
|
||||
[CommandStrings.Merge] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Merge] = [],
|
||||
|
||||
[CommandStrings.Reset] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Reset] = [],
|
||||
|
||||
[CommandStrings.SACD] = new List<string>()
|
||||
{
|
||||
[CommandStrings.SACD] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Start] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Start] = [],
|
||||
|
||||
[CommandStrings.Stop] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Stop] = [],
|
||||
|
||||
[CommandStrings.Sub] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Sub] = [],
|
||||
|
||||
[CommandStrings.Swap] = new List<string>()
|
||||
{
|
||||
[CommandStrings.Swap] =
|
||||
[
|
||||
FlagStrings.AddOffset,
|
||||
FlagStrings.BEOpcode,
|
||||
FlagStrings.C2Opcode,
|
||||
@@ -1549,48 +1531,44 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
FlagStrings.VideoNow,
|
||||
FlagStrings.VideoNowColor,
|
||||
FlagStrings.VideoNowXP,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.Tape] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Tape] = [],
|
||||
|
||||
[CommandStrings.Version] = new List<string>()
|
||||
{
|
||||
},
|
||||
[CommandStrings.Version] = [],
|
||||
|
||||
[CommandStrings.XBOX] = new List<string>()
|
||||
{
|
||||
[CommandStrings.XBOX] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
FlagStrings.DVDReread,
|
||||
FlagStrings.ForceUnitAccess,
|
||||
FlagStrings.NoSkipSS,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.XBOXSwap] = new List<string>()
|
||||
{
|
||||
[CommandStrings.XBOXSwap] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
FlagStrings.ForceUnitAccess,
|
||||
FlagStrings.NoSkipSS,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.XGD2Swap] = new List<string>()
|
||||
{
|
||||
[CommandStrings.XGD2Swap] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
FlagStrings.ForceUnitAccess,
|
||||
FlagStrings.NoSkipSS,
|
||||
},
|
||||
],
|
||||
|
||||
[CommandStrings.XGD3Swap] = new List<string>()
|
||||
{
|
||||
[CommandStrings.XGD3Swap] =
|
||||
[
|
||||
FlagStrings.DatExpand,
|
||||
FlagStrings.DisableBeep,
|
||||
FlagStrings.ForceUnitAccess,
|
||||
FlagStrings.NoSkipSS,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1813,7 +1791,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
StartLBAValue = null;
|
||||
EndLBAValue = null;
|
||||
|
||||
flags = new Dictionary<string, bool?>();
|
||||
flags = [];
|
||||
|
||||
AddOffsetValue = null;
|
||||
BEOpcodeValue = null;
|
||||
@@ -2697,25 +2675,25 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
if (line.StartsWith("DiscType:"))
|
||||
{
|
||||
// DiscType: <discType>
|
||||
string identifier = line.Substring("DiscType: ".Length);
|
||||
string identifier = line["DiscType: ".Length..];
|
||||
discTypeOrBookTypeSet.Add(identifier);
|
||||
}
|
||||
else if (line.StartsWith("DiscTypeIdentifier:"))
|
||||
{
|
||||
// DiscTypeIdentifier: <discType>
|
||||
string identifier = line.Substring("DiscTypeIdentifier: ".Length);
|
||||
string identifier = line["DiscTypeIdentifier: ".Length..];
|
||||
discTypeOrBookTypeSet.Add(identifier);
|
||||
}
|
||||
else if (line.StartsWith("DiscTypeSpecific:"))
|
||||
{
|
||||
// DiscTypeSpecific: <discType>
|
||||
string identifier = line.Substring("DiscTypeSpecific: ".Length);
|
||||
string identifier = line["DiscTypeSpecific: ".Length..];
|
||||
discTypeOrBookTypeSet.Add(identifier);
|
||||
}
|
||||
else if (line.StartsWith("BookType:"))
|
||||
{
|
||||
// BookType: <discType>
|
||||
string identifier = line.Substring("BookType: ".Length);
|
||||
string identifier = line["BookType: ".Length..];
|
||||
discTypeOrBookTypeSet.Add(identifier);
|
||||
}
|
||||
|
||||
@@ -2767,9 +2745,9 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
break;
|
||||
|
||||
if (line.StartsWith("CopyrightProtectionType"))
|
||||
copyrightProtectionSystemType = line.Substring("CopyrightProtectionType: ".Length);
|
||||
copyrightProtectionSystemType = line["CopyrightProtectionType: ".Length..];
|
||||
else if (line.StartsWith("RegionManagementInformation"))
|
||||
region = line.Substring("RegionManagementInformation: ".Length);
|
||||
region = line["RegionManagementInformation: ".Length..];
|
||||
|
||||
line = sr.ReadLine()?.Trim();
|
||||
}
|
||||
@@ -2792,7 +2770,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
|
||||
if (line.StartsWith("DecryptedDiscKey"))
|
||||
{
|
||||
decryptedDiscKey = line.Substring("DecryptedDiscKey[020]: ".Length);
|
||||
decryptedDiscKey = line["DecryptedDiscKey[020]: ".Length..];
|
||||
}
|
||||
else if (line.StartsWith("LBA:"))
|
||||
{
|
||||
@@ -2805,7 +2783,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
var match = Regex.Match(line, @"^LBA:\s*[0-9]+, Filename: (.*?), No TitleKey$", RegexOptions.Compiled);
|
||||
string matchedFilename = match.Groups[1].Value;
|
||||
if (matchedFilename.EndsWith(";1"))
|
||||
matchedFilename = matchedFilename.Substring(0, matchedFilename.Length - 2);
|
||||
matchedFilename = matchedFilename[..^2];
|
||||
|
||||
vobKeys += $"{matchedFilename} Title Key: No Title Key\n";
|
||||
}
|
||||
@@ -2814,7 +2792,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
var match = Regex.Match(line, @"^LBA:\s*[0-9]+, Filename: (.*?), EncryptedTitleKey: .*?, DecryptedTitleKey: (.*?)$", RegexOptions.Compiled);
|
||||
string matchedFilename = match.Groups[1].Value;
|
||||
if (matchedFilename.EndsWith(";1"))
|
||||
matchedFilename = matchedFilename.Substring(0, matchedFilename.Length - 2);
|
||||
matchedFilename = matchedFilename[..^2];
|
||||
|
||||
vobKeys += $"{matchedFilename} Title Key: {match.Groups[2].Value}\n";
|
||||
}
|
||||
@@ -2876,14 +2854,14 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
{
|
||||
totalErrors ??= 0;
|
||||
|
||||
if (Int64.TryParse(line.Substring("Total errors: ".Length).Trim(), out long te))
|
||||
if (Int64.TryParse(line["Total errors: ".Length..].Trim(), out long te))
|
||||
totalErrors += te;
|
||||
}
|
||||
else if (line.StartsWith("Total warnings"))
|
||||
{
|
||||
totalErrors ??= 0;
|
||||
|
||||
if (Int64.TryParse(line.Substring("Total warnings: ".Length).Trim(), out long tw))
|
||||
if (Int64.TryParse(line["Total warnings: ".Length..].Trim(), out long tw))
|
||||
totalErrors += tw;
|
||||
}
|
||||
}
|
||||
@@ -2915,11 +2893,11 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
try
|
||||
{
|
||||
string[] header = segaHeader!.Split('\n');
|
||||
string versionLine = header[4].Substring(58);
|
||||
string dateLine = header[5].Substring(58);
|
||||
serial = versionLine.Substring(0, 10).TrimEnd();
|
||||
string versionLine = header[4][58..];
|
||||
string dateLine = header[5][58..];
|
||||
serial = versionLine[..10].TrimEnd();
|
||||
version = versionLine.Substring(10, 6).TrimStart('V', 'v');
|
||||
date = dateLine.Substring(0, 8);
|
||||
date = dateLine[..8];
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
@@ -2956,17 +2934,17 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
if (string.IsNullOrEmpty(manufacturer) && line.StartsWith("VendorId"))
|
||||
{
|
||||
// VendorId: <manufacturer>
|
||||
manufacturer = line.Substring("VendorId: ".Length);
|
||||
manufacturer = line["VendorId: ".Length..];
|
||||
}
|
||||
else if (string.IsNullOrEmpty(model) && line.StartsWith("ProductId"))
|
||||
{
|
||||
// ProductId: <model>
|
||||
model = line.Substring("ProductId: ".Length);
|
||||
model = line["ProductId: ".Length..];
|
||||
}
|
||||
else if (string.IsNullOrEmpty(firmware) && line.StartsWith("ProductRevisionLevel"))
|
||||
{
|
||||
// ProductRevisionLevel: <firmware>
|
||||
firmware = line.Substring("ProductRevisionLevel: ".Length);
|
||||
firmware = line["ProductRevisionLevel: ".Length..];
|
||||
}
|
||||
|
||||
line = sr.ReadLine();
|
||||
@@ -3117,7 +3095,7 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
// TODO: Are there any examples of 3+ session discs?
|
||||
|
||||
// Read the first session lead-out
|
||||
var firstSessionLeadOutLengthString = line?.Substring("Lead-out length of 1st session: ".Length);
|
||||
var firstSessionLeadOutLengthString = line?["Lead-out length of 1st session: ".Length..];
|
||||
line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
return null;
|
||||
@@ -3126,12 +3104,12 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
string? secondSessionLeadInLengthString = null;
|
||||
while (line?.StartsWith("Lead-in length") == false)
|
||||
{
|
||||
secondSessionLeadInLengthString = line?.Substring("Lead-in length of 2nd session: ".Length);
|
||||
secondSessionLeadInLengthString = line?["Lead-in length of 2nd session: ".Length..];
|
||||
line = sr.ReadLine()?.Trim();
|
||||
}
|
||||
|
||||
// Read the second session pregap
|
||||
var secondSessionPregapLengthString = line?.Substring("Pregap length of 1st track of 2nd session: ".Length);
|
||||
var secondSessionPregapLengthString = line?["Pregap length of 1st track of 2nd session: ".Length..];
|
||||
|
||||
// Calculate the session gap total
|
||||
if (!int.TryParse(firstSessionLeadOutLengthString, out int firstSessionLeadOutLength))
|
||||
@@ -3355,11 +3333,11 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
try
|
||||
{
|
||||
string[] header = segaHeader!.Split('\n');
|
||||
string serialVersionLine = header[2].Substring(58);
|
||||
string dateLine = header[3].Substring(58);
|
||||
serial = serialVersionLine.Substring(0, 10).Trim();
|
||||
string serialVersionLine = header[2][58..];
|
||||
string dateLine = header[3][58..];
|
||||
serial = serialVersionLine[..10].Trim();
|
||||
version = serialVersionLine.Substring(10, 6).TrimStart('V', 'v');
|
||||
date = dateLine.Substring(0, 8);
|
||||
date = dateLine[..8];
|
||||
date = $"{date[0]}{date[1]}{date[2]}{date[3]}-{date[4]}{date[5]}-{date[6]}{date[7]}";
|
||||
return true;
|
||||
}
|
||||
@@ -3388,16 +3366,16 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
try
|
||||
{
|
||||
string[] header = segaHeader!.Split('\n');
|
||||
string serialVersionLine = header[8].Substring(58);
|
||||
string dateLine = header[1].Substring(58);
|
||||
string serialVersionLine = header[8][58..];
|
||||
string dateLine = header[1][58..];
|
||||
serial = serialVersionLine.Substring(3, 8).TrimEnd('-', ' ');
|
||||
date = dateLine.Substring(8).Trim();
|
||||
date = dateLine[8..].Trim();
|
||||
|
||||
// Properly format the date string, if possible
|
||||
string[] dateSplit = date.Split('.');
|
||||
|
||||
if (dateSplit.Length == 1)
|
||||
dateSplit = [date.Substring(0, 4), date.Substring(4)];
|
||||
dateSplit = [date[..4], date[4..]];
|
||||
|
||||
string month = dateSplit[1];
|
||||
dateSplit[1] = month switch
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
info.Artifacts ??= new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists($"{basePath}.cdtext"))
|
||||
info.Artifacts["cdtext"] = GetBase64(GetFullFile($"{basePath}.cdtext")) ?? string.Empty;
|
||||
@@ -525,7 +525,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
|
||||
ModeValues ??= new List<string> { CommandStrings.NONE };
|
||||
ModeValues ??= [CommandStrings.NONE];
|
||||
|
||||
// Modes
|
||||
parameters.AddRange(ModeValues);
|
||||
@@ -752,8 +752,8 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
return new Dictionary<string, List<string>>()
|
||||
{
|
||||
[CommandStrings.NONE] = new List<string>
|
||||
{
|
||||
[CommandStrings.NONE] =
|
||||
[
|
||||
// General
|
||||
FlagStrings.HelpLong,
|
||||
FlagStrings.HelpShort,
|
||||
@@ -799,7 +799,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
FlagStrings.Skip,
|
||||
FlagStrings.DumpReadSize,
|
||||
FlagStrings.OverreadLeadout,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -894,7 +894,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
BaseCommand = CommandStrings.NONE;
|
||||
|
||||
flags = new Dictionary<string, bool?>();
|
||||
flags = [];
|
||||
|
||||
// General
|
||||
DriveValue = null;
|
||||
@@ -943,18 +943,18 @@ namespace MPF.Core.Modules.Redumper
|
||||
case MediaType.CDROM:
|
||||
ModeValues = this.System switch
|
||||
{
|
||||
RedumpSystem.SuperAudioCD => new List<string> { CommandStrings.SACD },
|
||||
_ => new List<string> { CommandStrings.CD },
|
||||
RedumpSystem.SuperAudioCD => [CommandStrings.SACD],
|
||||
_ => [CommandStrings.CD],
|
||||
};
|
||||
break;
|
||||
case MediaType.DVD:
|
||||
ModeValues = new List<string> { CommandStrings.DVD };
|
||||
ModeValues = [CommandStrings.DVD];
|
||||
break;
|
||||
case MediaType.HDDVD: // TODO: Keep in sync if another command string shows up
|
||||
ModeValues = new List<string> { CommandStrings.DVD };
|
||||
ModeValues = [CommandStrings.DVD];
|
||||
break;
|
||||
case MediaType.BluRay:
|
||||
ModeValues = new List<string> { CommandStrings.BluRay };
|
||||
ModeValues = [CommandStrings.BluRay];
|
||||
break;
|
||||
default:
|
||||
BaseCommand = null;
|
||||
@@ -1023,7 +1023,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
.ToList();
|
||||
|
||||
// Setup the modes
|
||||
ModeValues = new List<string>();
|
||||
ModeValues = [];
|
||||
|
||||
// All modes should be cached separately
|
||||
int index = 0;
|
||||
@@ -1352,7 +1352,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
if (line.StartsWith("current profile:"))
|
||||
{
|
||||
// current profile: <discType>
|
||||
discTypeOrBookType = line.Substring("current profile: ".Length);
|
||||
discTypeOrBookType = line["current profile: ".Length..];
|
||||
}
|
||||
|
||||
line = sr.ReadLine();
|
||||
@@ -1394,17 +1394,17 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
if (line.StartsWith("protection system type"))
|
||||
{
|
||||
copyrightProtectionSystemType = line.Substring("protection system type: ".Length);
|
||||
copyrightProtectionSystemType = line["protection system type: ".Length..];
|
||||
if (copyrightProtectionSystemType == "none" || copyrightProtectionSystemType == "<none>")
|
||||
copyrightProtectionSystemType = "No";
|
||||
}
|
||||
else if (line.StartsWith("region management information:"))
|
||||
{
|
||||
region = line.Substring("region management information: ".Length);
|
||||
region = line["region management information: ".Length..];
|
||||
}
|
||||
else if (line.StartsWith("disc key"))
|
||||
{
|
||||
decryptedDiscKey = line.Substring("disc key: ".Length).Replace(':', ' ');
|
||||
decryptedDiscKey = line["disc key: ".Length..].Replace(':', ' ');
|
||||
}
|
||||
else if (line.StartsWith("title keys"))
|
||||
{
|
||||
@@ -1596,24 +1596,24 @@ namespace MPF.Core.Modules.Redumper
|
||||
else if (line.StartsWith("layer break:"))
|
||||
{
|
||||
// layer break: <layerbreak>
|
||||
layerbreak1 = line.Substring("layer break: ".Length).Trim();
|
||||
layerbreak1 = line["layer break: ".Length..].Trim();
|
||||
}
|
||||
|
||||
// Multi-layer discs have the layer in the name
|
||||
else if (line.StartsWith("layer break (layer: 0):"))
|
||||
{
|
||||
// layer break (layer: 0): <layerbreak>
|
||||
layerbreak1 = line.Substring("layer break (layer: 0): ".Length).Trim();
|
||||
layerbreak1 = line["layer break (layer: 0): ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("layer break (layer: 1):"))
|
||||
{
|
||||
// layer break (layer: 1): <layerbreak>
|
||||
layerbreak2 = line.Substring("layer break (layer: 1): ".Length).Trim();
|
||||
layerbreak2 = line["layer break (layer: 1): ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("layer break (layer: 2):"))
|
||||
{
|
||||
// layer break (layer: 2): <layerbreak>
|
||||
layerbreak3 = line.Substring("layer break (layer: 2): ".Length).Trim();
|
||||
layerbreak3 = line["layer break (layer: 2): ".Length..].Trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1658,11 +1658,11 @@ namespace MPF.Core.Modules.Redumper
|
||||
|
||||
// Store the first session range
|
||||
if (line.Contains("session 1:"))
|
||||
firstSession = line.Substring("session 1: ".Length).Trim();
|
||||
firstSession = line["session 1: ".Length..].Trim();
|
||||
|
||||
// Store the secomd session range
|
||||
else if (line.Contains("session 2:"))
|
||||
secondSession = line.Substring("session 2: ".Length).Trim();
|
||||
secondSession = line["session 2: ".Length..].Trim();
|
||||
}
|
||||
|
||||
// If either is blank, we don't have multisession
|
||||
@@ -1884,7 +1884,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
string? line = sr.ReadLine()?.TrimStart();
|
||||
if (line?.StartsWith("non-zero data sample range") == true)
|
||||
return line.Substring("non-zero data sample range: [".Length).Trim().Split(' ')[0];
|
||||
return line["non-zero data sample range: [".Length..].Trim().Split(' ')[0];
|
||||
}
|
||||
|
||||
// We couldn't detect it then
|
||||
@@ -1915,11 +1915,11 @@ namespace MPF.Core.Modules.Redumper
|
||||
try
|
||||
{
|
||||
string[] header = segaHeader!.Split('\n');
|
||||
string serialVersionLine = header[2].Substring(58);
|
||||
string dateLine = header[3].Substring(58);
|
||||
serial = serialVersionLine.Substring(0, 10).Trim();
|
||||
string serialVersionLine = header[2][58..];
|
||||
string dateLine = header[3][58..];
|
||||
serial = serialVersionLine[..10].Trim();
|
||||
version = serialVersionLine.Substring(10, 6).TrimStart('V', 'v');
|
||||
date = dateLine.Substring(0, 8);
|
||||
date = dateLine[..8];
|
||||
date = $"{date[0]}{date[1]}{date[2]}{date[3]}-{date[4]}{date[5]}-{date[6]}{date[7]}";
|
||||
return true;
|
||||
}
|
||||
@@ -2052,19 +2052,19 @@ namespace MPF.Core.Modules.Redumper
|
||||
|
||||
if (line.StartsWith("build date:"))
|
||||
{
|
||||
buildDate = line.Substring("build date: ".Length).Trim();
|
||||
buildDate = line["build date: ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("serial:"))
|
||||
{
|
||||
serial = line.Substring("serial: ".Length).Trim();
|
||||
serial = line["serial: ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("region:"))
|
||||
{
|
||||
region = line.Substring("region: ".Length).Trim();
|
||||
region = line["region: ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("regions:"))
|
||||
{
|
||||
region = line.Substring("regions: ".Length).Trim();
|
||||
region = line["regions: ".Length..].Trim();
|
||||
}
|
||||
else if (line.StartsWith("header:"))
|
||||
{
|
||||
@@ -2109,7 +2109,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
string? line = sr.ReadLine()?.TrimStart();
|
||||
if (line?.StartsWith("Universal Hash") == true)
|
||||
return line.Substring("Universal Hash (SHA-1): ".Length).Trim();
|
||||
return line["Universal Hash (SHA-1): ".Length..].Trim();
|
||||
}
|
||||
|
||||
// We couldn't detect it then
|
||||
@@ -2141,7 +2141,7 @@ namespace MPF.Core.Modules.Redumper
|
||||
{
|
||||
string? line = sr.ReadLine()?.TrimStart();
|
||||
if (line?.StartsWith("disc write offset") == true)
|
||||
return line.Substring("disc write offset: ".Length).Trim();
|
||||
return line["disc write offset: ".Length..].Trim();
|
||||
}
|
||||
|
||||
// We couldn't detect it then
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
info.Artifacts ??= new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt")) ?? string.Empty;
|
||||
@@ -203,7 +203,7 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
break;
|
||||
|
||||
if (line.StartsWith("TITLE") && title == null)
|
||||
title = line.Substring("TITLE: ".Length);
|
||||
title = line["TITLE: ".Length..];
|
||||
else if (line.StartsWith("DISC_VERSION") && umdversion == null)
|
||||
umdversion = line.Split(' ')[1];
|
||||
else if (line.StartsWith("pspUmdTypes"))
|
||||
|
||||
@@ -273,8 +273,8 @@ namespace MPF.Core
|
||||
info.DumpingInfo ??= new DumpingInfoSection();
|
||||
|
||||
// Ensure special dictionaries
|
||||
info.CommonDiscInfo.CommentsSpecialFields ??= new Dictionary<SiteCode, string>();
|
||||
info.CommonDiscInfo.ContentsSpecialFields ??= new Dictionary<SiteCode, string>();
|
||||
info.CommonDiscInfo.CommentsSpecialFields ??= [];
|
||||
info.CommonDiscInfo.ContentsSpecialFields ??= [];
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -496,7 +496,7 @@ namespace MPF.Core
|
||||
var (protectionString, fullProtections) = await InfoTool.GetCopyProtection(drive, options, protectionProgress);
|
||||
|
||||
info.CopyProtection!.Protection = protectionString;
|
||||
info.CopyProtection.FullProtections = fullProtections as Dictionary<string, List<string>?> ?? new Dictionary<string, List<string>?>();
|
||||
info.CopyProtection.FullProtections = fullProtections as Dictionary<string, List<string>?> ?? [];
|
||||
resultProgress?.Report(Result.Success("Copy protection scan complete!"));
|
||||
|
||||
break;
|
||||
@@ -668,7 +668,7 @@ namespace MPF.Core
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation2:
|
||||
info.CommonDiscInfo!.LanguageSelection = new LanguageSelection?[] { LanguageSelection.BiosSettings, LanguageSelection.LanguageSelector, LanguageSelection.OptionsMenu };
|
||||
info.CommonDiscInfo!.LanguageSelection = [LanguageSelection.BiosSettings, LanguageSelection.LanguageSelector, LanguageSelection.OptionsMenu];
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation3:
|
||||
@@ -734,7 +734,7 @@ namespace MPF.Core
|
||||
int firstParenLocation = title.IndexOf(" (");
|
||||
if (firstParenLocation >= 0)
|
||||
{
|
||||
info.CommonDiscInfo!.Title = title.Substring(0, firstParenLocation);
|
||||
info.CommonDiscInfo!.Title = title[..firstParenLocation];
|
||||
var subMatches = Constants.DiscNumberLetterRegex.Matches(title);
|
||||
foreach (Match subMatch in subMatches.Cast<Match>())
|
||||
{
|
||||
@@ -837,7 +837,7 @@ namespace MPF.Core
|
||||
tempDumpers.Add(WebUtility.HtmlDecode(submatch.Groups[1].Value));
|
||||
}
|
||||
|
||||
info.DumpersAndStatus.Dumpers = tempDumpers.ToArray();
|
||||
info.DumpersAndStatus.Dumpers = [.. tempDumpers];
|
||||
}
|
||||
|
||||
// TODO: Unify handling of fields that can include site codes (Comments/Contents)
|
||||
@@ -1093,7 +1093,7 @@ namespace MPF.Core
|
||||
// Set the current dumper based on username
|
||||
info.DumpersAndStatus ??= new DumpersAndStatusSection();
|
||||
info.DumpersAndStatus.Dumpers = [options.RedumpUsername!];
|
||||
info.PartiallyMatchedIDs = new List<int>();
|
||||
info.PartiallyMatchedIDs = [];
|
||||
|
||||
// Login to Redump
|
||||
#if NETFRAMEWORK
|
||||
@@ -1122,11 +1122,7 @@ namespace MPF.Core
|
||||
resultProgress?.Report(Result.Success("Finding disc matches on Redump..."));
|
||||
var splitData = info.TracksAndWriteOffsets?.ClrMameProData?.TrimEnd('\n')?.Split('\n');
|
||||
int trackCount = splitData?.Length ?? 0;
|
||||
#if NET40 || NET452
|
||||
foreach (string hashData in splitData ?? [])
|
||||
#else
|
||||
foreach (string hashData in splitData ?? Array.Empty<string>())
|
||||
#endif
|
||||
{
|
||||
// Catch any errant blank lines
|
||||
if (string.IsNullOrWhiteSpace(hashData))
|
||||
@@ -1165,7 +1161,7 @@ namespace MPF.Core
|
||||
// If no tracks were found, remove all fully matched IDs found so far
|
||||
else
|
||||
{
|
||||
fullyMatchedIDs = new List<int>();
|
||||
fullyMatchedIDs = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,15 +1181,12 @@ namespace MPF.Core
|
||||
// If no tracks were found, remove all fully matched IDs found so far
|
||||
else
|
||||
{
|
||||
fullyMatchedIDs = new List<int>();
|
||||
fullyMatchedIDs = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we only have unique IDs
|
||||
info.PartiallyMatchedIDs = info.PartiallyMatchedIDs
|
||||
.Distinct()
|
||||
.OrderBy(id => id)
|
||||
.ToList();
|
||||
info.PartiallyMatchedIDs = [.. info.PartiallyMatchedIDs.Distinct().OrderBy(id => id)];
|
||||
|
||||
resultProgress?.Report(Result.Success("Match finding complete! " + (fullyMatchedIDs != null && fullyMatchedIDs.Count > 0
|
||||
? "Fully Matched IDs: " + string.Join(",", fullyMatchedIDs)
|
||||
@@ -1496,7 +1489,7 @@ namespace MPF.Core
|
||||
}
|
||||
|
||||
// Format the universal hash for finding within the comments
|
||||
universalHash = $"{universalHash.Substring(0, universalHash.Length - 1)}/comments/only";
|
||||
universalHash = $"{universalHash[..^1]}/comments/only";
|
||||
|
||||
// Get all matching IDs for the hash
|
||||
var newIds = await ListSearchResults(wc, universalHash, filterForwardSlashes: false);
|
||||
|
||||
@@ -495,14 +495,14 @@ namespace MPF.Core.UI.ViewModels
|
||||
_options = OptionsLoader.LoadFromConfig();
|
||||
|
||||
// Added to clear warnings, all are set externally
|
||||
_drives = new List<Drive>();
|
||||
_driveSpeeds = new List<int>();
|
||||
_internalPrograms = new List<Element<InternalProgram>>();
|
||||
_drives = [];
|
||||
_driveSpeeds = [];
|
||||
_internalPrograms = [];
|
||||
_outputPath = string.Empty;
|
||||
_parameters = string.Empty;
|
||||
_startStopButtonText = string.Empty;
|
||||
_status = string.Empty;
|
||||
_systems = new List<RedumpSystemComboBoxItem>();
|
||||
_systems = [];
|
||||
|
||||
OptionsMenuItemEnabled = true;
|
||||
SystemTypeComboBoxEnabled = true;
|
||||
@@ -517,9 +517,9 @@ namespace MPF.Core.UI.ViewModels
|
||||
EnableParametersCheckBoxEnabled = true;
|
||||
LogPanelExpanded = _options.OpenLogWindowAtStartup;
|
||||
|
||||
MediaTypes = new List<Element<MediaType>>();
|
||||
MediaTypes = [];
|
||||
Systems = RedumpSystemComboBoxItem.GenerateElements().ToList();
|
||||
InternalPrograms = new List<Element<InternalProgram>>();
|
||||
InternalPrograms = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -764,7 +764,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
SchemaVersion = 1,
|
||||
FullyMatchedID = 3,
|
||||
PartiallyMatchedIDs = new List<int> { 0, 1, 2, 3 },
|
||||
PartiallyMatchedIDs = [0, 1, 2, 3],
|
||||
Added = DateTime.UtcNow,
|
||||
LastModified = DateTime.UtcNow,
|
||||
|
||||
@@ -778,8 +778,8 @@ namespace MPF.Core.UI.ViewModels
|
||||
DiscTitle = "Install Disc",
|
||||
Category = DiscCategory.Games,
|
||||
Region = Region.World,
|
||||
Languages = new Language?[] { Language.English, Language.Spanish, Language.French },
|
||||
LanguageSelection = new LanguageSelection?[] { LanguageSelection.BiosSettings },
|
||||
Languages = [Language.English, Language.Spanish, Language.French],
|
||||
LanguageSelection = [LanguageSelection.BiosSettings],
|
||||
Serial = "Disc Serial",
|
||||
Layer0MasteringRing = "L0 Mastering Ring",
|
||||
Layer0MasteringSID = "L0 Mastering SID",
|
||||
@@ -817,7 +817,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
Version = "Original",
|
||||
VersionDatfile = "Alt",
|
||||
CommonEditions = new string[] { "Taikenban" },
|
||||
CommonEditions = ["Taikenban"],
|
||||
OtherEditions = "Rerelease",
|
||||
},
|
||||
|
||||
@@ -855,7 +855,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
DumpersAndStatus = new DumpersAndStatusSection()
|
||||
{
|
||||
Status = DumpStatus.TwoOrMoreGreen,
|
||||
Dumpers = new string[] { "Dumper1", "Dumper2" },
|
||||
Dumpers = ["Dumper1", "Dumper2"],
|
||||
OtherDumpers = "Dumper3",
|
||||
},
|
||||
|
||||
@@ -863,7 +863,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
ClrMameProData = "Datfile",
|
||||
Cuesheet = "Cuesheet",
|
||||
CommonWriteOffsets = new int[] { 0, 12, -12 },
|
||||
CommonWriteOffsets = [0, 12, -12],
|
||||
OtherWriteOffsets = "-2",
|
||||
},
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ using SabreTools.RedumpLib.Web;
|
||||
|
||||
namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
public class OptionsViewModel : INotifyPropertyChanged
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public class OptionsViewModel(Options baseOptions) : INotifyPropertyChanged
|
||||
{
|
||||
#region Fields
|
||||
|
||||
@@ -29,7 +32,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Current set of options
|
||||
/// </summary>
|
||||
public Options Options { get; }
|
||||
public Options Options { get; } = new Options(baseOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Flag for if settings were saved or not
|
||||
@@ -55,14 +58,6 @@ namespace MPF.Core.UI.ViewModels
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public OptionsViewModel(Options baseOptions)
|
||||
{
|
||||
Options = new Options(baseOptions);
|
||||
}
|
||||
|
||||
#region Population
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.0</VersionPrefix>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace MPF.UI.Core.Windows
|
||||
return;
|
||||
|
||||
// Strips button prefix to obtain the setting name
|
||||
string pathSettingName = button.Name.Substring(0, button.Name.IndexOf("Button"));
|
||||
string pathSettingName = button.Name[..button.Name.IndexOf("Button")];
|
||||
|
||||
// TODO: hack for now, then we'll see
|
||||
bool shouldBrowseForPath = pathSettingName == "DefaultOutputPath";
|
||||
|
||||
Reference in New Issue
Block a user