mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Clean up based on .NET Core 3.1 reccomendations
This commit is contained in:
@@ -1727,9 +1727,9 @@ namespace SabreTools.Core.Tools
|
|||||||
{
|
{
|
||||||
return supported switch
|
return supported switch
|
||||||
{
|
{
|
||||||
Supported.No => "no",
|
Supported.No => verbose ? "unsupported" : "no",
|
||||||
Supported.Partial => "partial",
|
Supported.Partial => "partial",
|
||||||
Supported.Yes => "yes",
|
Supported.Yes => verbose ? "supported" : "yes",
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,88 +70,37 @@ namespace SabreTools.DatFiles
|
|||||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||||
public static DatFile Create(DatFormat? datFormat = null, DatFile baseDat = null, bool quotes = true)
|
public static DatFile Create(DatFormat? datFormat = null, DatFile baseDat = null, bool quotes = true)
|
||||||
{
|
{
|
||||||
switch (datFormat)
|
return datFormat switch
|
||||||
{
|
{
|
||||||
case DatFormat.AttractMode:
|
DatFormat.AttractMode => new AttractMode(baseDat),
|
||||||
return new AttractMode(baseDat);
|
DatFormat.ClrMamePro => new ClrMamePro(baseDat, quotes),
|
||||||
|
DatFormat.CSV => new SeparatedValue(baseDat, ','),
|
||||||
case DatFormat.ClrMamePro:
|
DatFormat.DOSCenter => new DosCenter(baseDat),
|
||||||
return new ClrMamePro(baseDat, quotes);
|
DatFormat.EverdriveSMDB => new EverdriveSMDB(baseDat),
|
||||||
|
DatFormat.Listrom => new Listrom(baseDat),
|
||||||
case DatFormat.CSV:
|
DatFormat.Listxml => new Listxml(baseDat),
|
||||||
return new Formats.SeparatedValue(baseDat, ',');
|
DatFormat.Logiqx => new Logiqx(baseDat, false),
|
||||||
|
DatFormat.LogiqxDeprecated => new Logiqx(baseDat, true),
|
||||||
case DatFormat.DOSCenter:
|
DatFormat.MissFile => new Missfile(baseDat),
|
||||||
return new DosCenter(baseDat);
|
DatFormat.OfflineList => new OfflineList(baseDat),
|
||||||
|
DatFormat.OpenMSX => new OpenMSX(baseDat),
|
||||||
case DatFormat.EverdriveSMDB:
|
DatFormat.RedumpMD5 => new Hashfile(baseDat, Hash.MD5),
|
||||||
return new EverdriveSMDB(baseDat);
|
DatFormat.RedumpSFV => new Hashfile(baseDat, Hash.CRC),
|
||||||
|
DatFormat.RedumpSHA1 => new Hashfile(baseDat, Hash.SHA1),
|
||||||
case DatFormat.Listrom:
|
DatFormat.RedumpSHA256 => new Hashfile(baseDat, Hash.SHA256),
|
||||||
return new Listrom(baseDat);
|
DatFormat.RedumpSHA384 => new Hashfile(baseDat, Hash.SHA384),
|
||||||
|
DatFormat.RedumpSHA512 => new Hashfile(baseDat, Hash.SHA512),
|
||||||
case DatFormat.Listxml:
|
DatFormat.RedumpSpamSum => new Hashfile(baseDat, Hash.SpamSum),
|
||||||
return new Listxml(baseDat);
|
DatFormat.RomCenter => new RomCenter(baseDat),
|
||||||
|
DatFormat.SabreJSON => new SabreJSON(baseDat),
|
||||||
case DatFormat.Logiqx:
|
DatFormat.SabreXML => new SabreXML(baseDat),
|
||||||
return new Logiqx(baseDat, false);
|
DatFormat.SoftwareList => new Formats.SoftwareList(baseDat),
|
||||||
|
DatFormat.SSV => new SeparatedValue(baseDat, ';'),
|
||||||
case DatFormat.LogiqxDeprecated:
|
DatFormat.TSV => new SeparatedValue(baseDat, '\t'),
|
||||||
return new Logiqx(baseDat, true);
|
|
||||||
|
|
||||||
case DatFormat.MissFile:
|
|
||||||
return new Missfile(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.OfflineList:
|
|
||||||
return new OfflineList(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.OpenMSX:
|
|
||||||
return new OpenMSX(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.RedumpMD5:
|
|
||||||
return new Hashfile(baseDat, Hash.MD5);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSFV:
|
|
||||||
return new Hashfile(baseDat, Hash.CRC);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSHA1:
|
|
||||||
return new Hashfile(baseDat, Hash.SHA1);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSHA256:
|
|
||||||
return new Hashfile(baseDat, Hash.SHA256);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSHA384:
|
|
||||||
return new Hashfile(baseDat, Hash.SHA384);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSHA512:
|
|
||||||
return new Hashfile(baseDat, Hash.SHA512);
|
|
||||||
|
|
||||||
case DatFormat.RedumpSpamSum:
|
|
||||||
return new Hashfile(baseDat, Hash.SpamSum);
|
|
||||||
|
|
||||||
case DatFormat.RomCenter:
|
|
||||||
return new RomCenter(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.SabreJSON:
|
|
||||||
return new SabreJSON(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.SabreXML:
|
|
||||||
return new SabreXML(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.SoftwareList:
|
|
||||||
return new Formats.SoftwareList(baseDat);
|
|
||||||
|
|
||||||
case DatFormat.SSV:
|
|
||||||
return new Formats.SeparatedValue(baseDat, ';');
|
|
||||||
|
|
||||||
case DatFormat.TSV:
|
|
||||||
return new Formats.SeparatedValue(baseDat, '\t');
|
|
||||||
|
|
||||||
// We use new-style Logiqx as a backup for generic DatFile
|
// We use new-style Logiqx as a backup for generic DatFile
|
||||||
case null:
|
_ => new Logiqx(baseDat, false),
|
||||||
default:
|
};
|
||||||
return new Logiqx(baseDat, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -213,7 +162,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// <returns>The key for the item</returns>
|
/// <returns>The key for the item</returns>
|
||||||
protected string ParseAddHelper(DatItem item)
|
protected string ParseAddHelper(DatItem item)
|
||||||
{
|
{
|
||||||
string key = string.Empty;
|
string key;
|
||||||
|
|
||||||
// If we have a Disk, Media, or Rom, clean the hash data
|
// If we have a Disk, Media, or Rom, clean the hash data
|
||||||
if (item.ItemType == ItemType.Disk)
|
if (item.ItemType == ItemType.Disk)
|
||||||
@@ -344,7 +293,7 @@ namespace SabreTools.DatFiles
|
|||||||
protected string CreatePrefixPostfix(DatItem item, bool prefix)
|
protected string CreatePrefixPostfix(DatItem item, bool prefix)
|
||||||
{
|
{
|
||||||
// Initialize strings
|
// Initialize strings
|
||||||
string fix = string.Empty,
|
string fix,
|
||||||
game = item.Machine.Name,
|
game = item.Machine.Name,
|
||||||
name = item.GetName() ?? item.ItemType.ToString(),
|
name = item.GetName() ?? item.ItemType.ToString(),
|
||||||
crc = string.Empty,
|
crc = string.Empty,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = svr.Line[1].Substring(fullname[0].Length + 1),
|
Name = svr.Line[1][(fullname[0].Length + 1)..],
|
||||||
Size = null, // No size provided, but we don't want the size being 0
|
Size = null, // No size provided, but we don't want the size being 0
|
||||||
CRC = svr.Line[4],
|
CRC = svr.Line[4],
|
||||||
MD5 = svr.Line[3],
|
MD5 = svr.Line[3],
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the hash field and set final fields
|
// Get the hash field and set final fields
|
||||||
string hash = string.Empty;
|
string hash;
|
||||||
switch (_hash)
|
switch (_hash)
|
||||||
{
|
{
|
||||||
case Hash.CRC:
|
case Hash.CRC:
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
logger.Warning($"Possibly malformed line: '{line}'");
|
logger.Warning($"Possibly malformed line: '{line}'");
|
||||||
|
|
||||||
string romname = split[0];
|
string romname = split[0];
|
||||||
line = line.Substring(romname.Length);
|
line = line[romname.Length..];
|
||||||
|
|
||||||
// Next we separate the ROM into pieces
|
// Next we separate the ROM into pieces
|
||||||
split = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
|
split = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|||||||
@@ -398,8 +398,6 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Otherwise, add what is possible
|
// Otherwise, add what is possible
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
string key = string.Empty;
|
|
||||||
string temptype = reader.Name;
|
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
|
|
||||||
// Create a new machine
|
// Create a new machine
|
||||||
@@ -497,7 +495,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
archive.CopyMachineInformation(machine);
|
archive.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the archive
|
// Now process and add the archive
|
||||||
key = ParseAddHelper(archive);
|
ParseAddHelper(archive);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -521,7 +519,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
biosSet.CopyMachineInformation(machine);
|
biosSet.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the biosSet
|
// Now process and add the biosSet
|
||||||
key = ParseAddHelper(biosSet);
|
ParseAddHelper(biosSet);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -547,7 +545,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
disk.CopyMachineInformation(machine);
|
disk.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the disk
|
// Now process and add the disk
|
||||||
key = ParseAddHelper(disk);
|
ParseAddHelper(disk);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -573,7 +571,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
media.CopyMachineInformation(machine);
|
media.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the media
|
// Now process and add the media
|
||||||
key = ParseAddHelper(media);
|
ParseAddHelper(media);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -593,7 +591,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
release.CopyMachineInformation(machine);
|
release.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the release
|
// Now process and add the release
|
||||||
key = ParseAddHelper(release);
|
ParseAddHelper(release);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -627,7 +625,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
rom.CopyMachineInformation(machine);
|
rom.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the rom
|
// Now process and add the rom
|
||||||
key = ParseAddHelper(rom);
|
ParseAddHelper(rom);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -649,7 +647,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
sample.CopyMachineInformation(machine);
|
sample.CopyMachineInformation(machine);
|
||||||
|
|
||||||
// Now process and add the sample
|
// Now process and add the sample
|
||||||
key = ParseAddHelper(sample);
|
ParseAddHelper(sample);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return base.CreateProperties(type, memberSerialization)
|
return base.CreateProperties(type, memberSerialization)
|
||||||
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList();
|
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList();
|
||||||
|
|
||||||
IEnumerable<Type> BaseTypesAndSelf(Type t)
|
static IEnumerable<Type> BaseTypesAndSelf(Type t)
|
||||||
{
|
{
|
||||||
while (t != null)
|
while (t != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal dictionary for the class
|
/// Internal dictionary for the class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ConcurrentDictionary<string, List<DatItem>> items;
|
private readonly ConcurrentDictionary<string, List<DatItem>> items;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lock for statistics calculation
|
/// Lock for statistics calculation
|
||||||
@@ -44,12 +44,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Logger logger;
|
private readonly Logger logger;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Static logger for static methods
|
|
||||||
/// </summary>
|
|
||||||
private static Logger staticLogger = new Logger();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ namespace SabreTools.DatItems
|
|||||||
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
||||||
{
|
{
|
||||||
// Set the output key as the default blank string
|
// Set the output key as the default blank string
|
||||||
string key = string.Empty;
|
string key;
|
||||||
|
|
||||||
// Now determine what the key should be based on the bucketedBy value
|
// Now determine what the key should be based on the bucketedBy value
|
||||||
switch (bucketedBy)
|
switch (bucketedBy)
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace SabreTools.DatItems
|
|||||||
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
||||||
{
|
{
|
||||||
// Set the output key as the default blank string
|
// Set the output key as the default blank string
|
||||||
string key = string.Empty;
|
string key;
|
||||||
|
|
||||||
// Now determine what the key should be based on the bucketedBy value
|
// Now determine what the key should be based on the bucketedBy value
|
||||||
switch (bucketedBy)
|
switch (bucketedBy)
|
||||||
|
|||||||
@@ -629,7 +629,7 @@ namespace SabreTools.DatItems
|
|||||||
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
||||||
{
|
{
|
||||||
// Set the output key as the default blank string
|
// Set the output key as the default blank string
|
||||||
string key = string.Empty;
|
string key;
|
||||||
|
|
||||||
// Now determine what the key should be based on the bucketedBy value
|
// Now determine what the key should be based on the bucketedBy value
|
||||||
switch (bucketedBy)
|
switch (bucketedBy)
|
||||||
|
|||||||
@@ -415,22 +415,22 @@ namespace SabreTools.DatTools
|
|||||||
// If we have a Disk, then the ".chd" extension needs to be removed
|
// If we have a Disk, then the ".chd" extension needs to be removed
|
||||||
if (datItem.ItemType == ItemType.Disk && itemName.EndsWith(".chd"))
|
if (datItem.ItemType == ItemType.Disk && itemName.EndsWith(".chd"))
|
||||||
{
|
{
|
||||||
itemName = itemName.Substring(0, itemName.Length - 4);
|
itemName = itemName[0..^4];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a Media, then the extension needs to be removed
|
// If we have a Media, then the extension needs to be removed
|
||||||
else if (datItem.ItemType == ItemType.Media)
|
else if (datItem.ItemType == ItemType.Media)
|
||||||
{
|
{
|
||||||
if (itemName.EndsWith(".dicf"))
|
if (itemName.EndsWith(".dicf"))
|
||||||
itemName = itemName.Substring(0, itemName.Length - 5);
|
itemName = itemName[0..^5];
|
||||||
else if (itemName.EndsWith(".aaru"))
|
else if (itemName.EndsWith(".aaru"))
|
||||||
itemName = itemName.Substring(0, itemName.Length - 5);
|
itemName = itemName[0..^5];
|
||||||
else if (itemName.EndsWith(".aaruformat"))
|
else if (itemName.EndsWith(".aaruformat"))
|
||||||
itemName = itemName.Substring(0, itemName.Length - 11);
|
itemName = itemName[0..^11];
|
||||||
else if (itemName.EndsWith(".aaruf"))
|
else if (itemName.EndsWith(".aaruf"))
|
||||||
itemName = itemName.Substring(0, itemName.Length - 6);
|
itemName = itemName[0..^6];
|
||||||
else if (itemName.EndsWith(".aif"))
|
else if (itemName.EndsWith(".aif"))
|
||||||
itemName = itemName.Substring(0, itemName.Length - 4);
|
itemName = itemName[0..^4];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the item name back
|
// Set the item name back
|
||||||
|
|||||||
@@ -158,23 +158,21 @@ namespace SabreTools.DatTools
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (StreamReader sr = File.OpenText(filename))
|
using StreamReader sr = File.OpenText(filename);
|
||||||
|
first = sr.ReadLine().ToLowerInvariant();
|
||||||
|
while ((string.IsNullOrWhiteSpace(first) || first.StartsWith("<!--"))
|
||||||
|
&& !sr.EndOfStream)
|
||||||
{
|
{
|
||||||
first = sr.ReadLine().ToLowerInvariant();
|
first = sr.ReadLine().ToLowerInvariant();
|
||||||
while ((string.IsNullOrWhiteSpace(first) || first.StartsWith("<!--"))
|
}
|
||||||
|
|
||||||
|
if (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
second = sr.ReadLine().ToLowerInvariant();
|
||||||
|
while (string.IsNullOrWhiteSpace(second) || second.StartsWith("<!--")
|
||||||
&& !sr.EndOfStream)
|
&& !sr.EndOfStream)
|
||||||
{
|
|
||||||
first = sr.ReadLine().ToLowerInvariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sr.EndOfStream)
|
|
||||||
{
|
{
|
||||||
second = sr.ReadLine().ToLowerInvariant();
|
second = sr.ReadLine().ToLowerInvariant();
|
||||||
while (string.IsNullOrWhiteSpace(second) || second.StartsWith("<!--")
|
|
||||||
&& !sr.EndOfStream)
|
|
||||||
{
|
|
||||||
second = sr.ReadLine().ToLowerInvariant();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,8 @@ namespace SabreTools.FileTypes.Aaru
|
|||||||
/// <param name="filename">Filename respresenting the AaruFormat file</param>
|
/// <param name="filename">Filename respresenting the AaruFormat file</param>
|
||||||
public static AaruFormat Create(string filename)
|
public static AaruFormat Create(string filename)
|
||||||
{
|
{
|
||||||
using (FileStream fs = File.OpenRead(filename))
|
using FileStream fs = File.OpenRead(filename);
|
||||||
{
|
return Create(fs);
|
||||||
return Create(fs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -227,12 +227,11 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
if (this.AvailableHashes == Hash.CRC)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
gzipEntryRom.Filename = gamename;
|
gzipEntryRom.Filename = gamename;
|
||||||
using (BinaryReader br = new BinaryReader(File.OpenRead(this.Filename)))
|
|
||||||
{
|
using BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||||
br.BaseStream.Seek(-8, SeekOrigin.End);
|
br.BaseStream.Seek(-8, SeekOrigin.End);
|
||||||
gzipEntryRom.CRC = br.ReadBytesBigEndian(4);
|
gzipEntryRom.CRC = br.ReadBytesBigEndian(4);
|
||||||
gzipEntryRom.Size = br.ReadInt32BigEndian();
|
gzipEntryRom.Size = br.ReadInt32BigEndian();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -178,10 +178,8 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (Stream entryStream = entry.OpenEntryStream())
|
using Stream entryStream = entry.OpenEntryStream();
|
||||||
{
|
rarEntryRom = GetInfo(entryStream, size: entry.Size, hashes: this.AvailableHashes);
|
||||||
rarEntryRom = GetInfo(entryStream, size: entry.Size, hashes: this.AvailableHashes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in comon details and add to the list
|
// Fill in comon details and add to the list
|
||||||
|
|||||||
@@ -183,10 +183,8 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (Stream entryStream = entry.OpenEntryStream())
|
using Stream entryStream = entry.OpenEntryStream();
|
||||||
{
|
tarEntryRom = GetInfo(entryStream, size: entry.Size, hashes: this.AvailableHashes);
|
||||||
tarEntryRom = GetInfo(entryStream, size: entry.Size, hashes: this.AvailableHashes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in comon details and add to the list
|
// Fill in comon details and add to the list
|
||||||
|
|||||||
@@ -211,12 +211,11 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
if (this.AvailableHashes == Hash.CRC)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
xzEntryRom.Filename = gamename;
|
xzEntryRom.Filename = gamename;
|
||||||
using (BinaryReader br = new BinaryReader(File.OpenRead(this.Filename)))
|
|
||||||
{
|
using BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||||
br.BaseStream.Seek(-8, SeekOrigin.End);
|
br.BaseStream.Seek(-8, SeekOrigin.End);
|
||||||
xzEntryRom.CRC = br.ReadBytesBigEndian(4);
|
xzEntryRom.CRC = br.ReadBytesBigEndian(4);
|
||||||
xzEntryRom.Size = br.ReadInt32BigEndian();
|
xzEntryRom.Size = br.ReadInt32BigEndian();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -99,26 +99,15 @@ namespace SabreTools.FileTypes
|
|||||||
/// <returns>Archive object representing the inputs</returns>
|
/// <returns>Archive object representing the inputs</returns>
|
||||||
public static BaseArchive Create(FileType archiveType)
|
public static BaseArchive Create(FileType archiveType)
|
||||||
{
|
{
|
||||||
switch (archiveType)
|
return archiveType switch
|
||||||
{
|
{
|
||||||
case FileType.GZipArchive:
|
FileType.GZipArchive => new GZipArchive(),
|
||||||
return new GZipArchive();
|
FileType.RarArchive => new RarArchive(),
|
||||||
|
FileType.SevenZipArchive => new SevenZipArchive(),
|
||||||
case FileType.RarArchive:
|
FileType.TapeArchive => new TapeArchive(),
|
||||||
return new RarArchive();
|
FileType.ZipArchive => new ZipArchive(),
|
||||||
|
_ => null,
|
||||||
case FileType.SevenZipArchive:
|
};
|
||||||
return new SevenZipArchive();
|
|
||||||
|
|
||||||
case FileType.TapeArchive:
|
|
||||||
return new TapeArchive();
|
|
||||||
|
|
||||||
case FileType.ZipArchive:
|
|
||||||
return new ZipArchive();
|
|
||||||
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -29,10 +29,8 @@ namespace SabreTools.FileTypes.CHD
|
|||||||
/// <param name="filename">Filename respresenting the CHD file</param>
|
/// <param name="filename">Filename respresenting the CHD file</param>
|
||||||
public static CHDFile Create(string filename)
|
public static CHDFile Create(string filename)
|
||||||
{
|
{
|
||||||
using (FileStream fs = File.OpenRead(filename))
|
using FileStream fs = File.OpenRead(filename);
|
||||||
{
|
return Create(fs);
|
||||||
return Create(fs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -108,21 +106,15 @@ namespace SabreTools.FileTypes.CHD
|
|||||||
if (!string.Equals(new string(tag), "MComprHD", StringComparison.Ordinal))
|
if (!string.Equals(new string(tag), "MComprHD", StringComparison.Ordinal))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (version)
|
return version switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => length == CHDFileV1.HeaderSize ? version : 0,
|
||||||
return length == CHDFileV1.HeaderSize ? version : 0;
|
2 => length == CHDFileV2.HeaderSize ? version : 0,
|
||||||
case 2:
|
3 => length == CHDFileV3.HeaderSize ? version : 0,
|
||||||
return length == CHDFileV2.HeaderSize ? version : 0;
|
4 => length == CHDFileV4.HeaderSize ? version : 0,
|
||||||
case 3:
|
5 => length == CHDFileV5.HeaderSize ? version : 0,
|
||||||
return length == CHDFileV3.HeaderSize ? version : 0;
|
_ => 0,
|
||||||
case 4:
|
};
|
||||||
return length == CHDFileV4.HeaderSize ? version : 0;
|
|
||||||
case 5:
|
|
||||||
return length == CHDFileV5.HeaderSize ? version : 0;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -133,21 +125,15 @@ namespace SabreTools.FileTypes.CHD
|
|||||||
/// <returns>Populated CHD file, null on failure</returns>
|
/// <returns>Populated CHD file, null on failure</returns>
|
||||||
private static CHDFile ReadAsVersion(Stream stream, uint version)
|
private static CHDFile ReadAsVersion(Stream stream, uint version)
|
||||||
{
|
{
|
||||||
switch (version)
|
return version switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => CHDFileV1.Deserialize(stream),
|
||||||
return CHDFileV1.Deserialize(stream);
|
2 => CHDFileV2.Deserialize(stream),
|
||||||
case 2:
|
3 => CHDFileV3.Deserialize(stream),
|
||||||
return CHDFileV2.Deserialize(stream);
|
4 => CHDFileV4.Deserialize(stream),
|
||||||
case 3:
|
5 => CHDFileV5.Deserialize(stream),
|
||||||
return CHDFileV3.Deserialize(stream);
|
_ => null,
|
||||||
case 4:
|
};
|
||||||
return CHDFileV4.Deserialize(stream);
|
|
||||||
case 5:
|
|
||||||
return CHDFileV5.Deserialize(stream);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace SabreTools.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Flag specific to Folder to omit Machine name from output path
|
/// Flag specific to Folder to omit Machine name from output path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool writeToParent = false;
|
private readonly bool writeToParent = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
string inputTrimmed = input.Trim('"', ' ', '\t');
|
string inputTrimmed = input.Trim('"', ' ', '\t');
|
||||||
string fieldString = inputTrimmed.Split(':')[0].ToLowerInvariant().Trim('"', ' ', '\t');
|
string fieldString = inputTrimmed.Split(':')[0].ToLowerInvariant().Trim('"', ' ', '\t');
|
||||||
string fileString = inputTrimmed.Substring(fieldString.Length + 1).Trim('"', ' ', '\t');
|
string fileString = inputTrimmed[(fieldString.Length + 1)..].Trim('"', ' ', '\t');
|
||||||
|
|
||||||
item.DatItemField = fieldString.AsDatItemField();
|
item.DatItemField = fieldString.AsDatItemField();
|
||||||
item.MachineField = fieldString.AsMachineField();
|
item.MachineField = fieldString.AsMachineField();
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ namespace SabreTools.Filtering
|
|||||||
|| filterTrimmed.StartsWith("~")
|
|| filterTrimmed.StartsWith("~")
|
||||||
|| filterTrimmed.StartsWith("not-");
|
|| filterTrimmed.StartsWith("not-");
|
||||||
filterTrimmed = filterTrimmed.TrimStart('!', '~');
|
filterTrimmed = filterTrimmed.TrimStart('!', '~');
|
||||||
filterTrimmed = filterTrimmed.StartsWith("not-") ? filterTrimmed.Substring(4) : filterTrimmed;
|
filterTrimmed = filterTrimmed.StartsWith("not-") ? filterTrimmed[4..] : filterTrimmed;
|
||||||
|
|
||||||
string filterFieldString = filterTrimmed.Split(':')[0].ToLowerInvariant().Trim('"', ' ', '\t');
|
string filterFieldString = filterTrimmed.Split(':')[0].ToLowerInvariant().Trim('"', ' ', '\t');
|
||||||
string filterValue = filterTrimmed.Substring(filterFieldString.Length + 1).Trim('"', ' ', '\t');
|
string filterValue = filterTrimmed[(filterFieldString.Length + 1)..].Trim('"', ' ', '\t');
|
||||||
|
|
||||||
return (filterFieldString, filterValue, negate);
|
return (filterFieldString, filterValue, negate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,9 +153,8 @@ namespace SabreTools.Filtering
|
|||||||
{
|
{
|
||||||
if (straw is string)
|
if (straw is string)
|
||||||
{
|
{
|
||||||
string needleString = needle as string;
|
|
||||||
string strawString = straw as string;
|
string strawString = straw as string;
|
||||||
if (!string.IsNullOrWhiteSpace(strawString) && needleString != null)
|
if (!string.IsNullOrWhiteSpace(strawString) && needle is string needleString)
|
||||||
{
|
{
|
||||||
string regexStraw = strawString;
|
string regexStraw = strawString;
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ namespace SabreTools.Help
|
|||||||
{
|
{
|
||||||
#region Private variables
|
#region Private variables
|
||||||
|
|
||||||
private List<string> _header;
|
private readonly List<string> _header;
|
||||||
private Dictionary<string, Feature> _features;
|
private Dictionary<string, Feature> _features;
|
||||||
private static string _barrier = "-----------------------------------------";
|
private const string _barrier = "-----------------------------------------";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -155,16 +155,18 @@ namespace SabreTools.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OutputCredits()
|
public void OutputCredits()
|
||||||
{
|
{
|
||||||
List<string> credits = new List<string>();
|
List<string> credits = new List<string>
|
||||||
credits.Add(_barrier);
|
{
|
||||||
credits.Add("Credits");
|
_barrier,
|
||||||
credits.Add(_barrier);
|
"Credits",
|
||||||
credits.Add(string.Empty);
|
_barrier,
|
||||||
credits.Add("Programmer / Lead: Matt Nadareski (darksabre76)");
|
string.Empty,
|
||||||
credits.Add("Additional code: emuLOAD, @tractivo, motoschifo");
|
"Programmer / Lead: Matt Nadareski (darksabre76)",
|
||||||
credits.Add("Testing: emuLOAD, @tractivo, Kludge, Obiwantje, edc");
|
"Additional code: emuLOAD, @tractivo, motoschifo",
|
||||||
credits.Add("Suggestions: edc, AcidX, Amiga12, EliUmniCk");
|
"Testing: emuLOAD, @tractivo, Kludge, Obiwantje, edc",
|
||||||
credits.Add("Based on work by: The Wizard of DATz");
|
"Suggestions: edc, AcidX, Amiga12, EliUmniCk",
|
||||||
|
"Based on work by: The Wizard of DATz"
|
||||||
|
};
|
||||||
WriteOutWithPauses(credits);
|
WriteOutWithPauses(credits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace SabreTools.IO.Readers
|
|||||||
// Standalone (special case for DC dats)
|
// Standalone (special case for DC dats)
|
||||||
if (CurrentLine.StartsWith("Name:"))
|
if (CurrentLine.StartsWith("Name:"))
|
||||||
{
|
{
|
||||||
string temp = CurrentLine.Substring("Name:".Length).Trim();
|
string temp = CurrentLine["Name:".Length..].Trim();
|
||||||
CurrentLine = $"Name: {temp}";
|
CurrentLine = $"Name: {temp}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace SabreTools.IO.Writers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal stream writer
|
/// Internal stream writer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private StreamWriter sw;
|
private readonly StreamWriter sw;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stack for tracking current node
|
/// Stack for tracking current node
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace SabreTools.IO.Writers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal stream writer for outputting
|
/// Internal stream writer for outputting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private StreamWriter sw;
|
private readonly StreamWriter sw;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for writing to a file
|
/// Constructor for writing to a file
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace SabreTools.IO.Writers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal stream writer for outputting
|
/// Internal stream writer for outputting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private StreamWriter sw;
|
private readonly StreamWriter sw;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal value if we've written a header before
|
/// Internal value if we've written a header before
|
||||||
|
|||||||
Reference in New Issue
Block a user