Remove .NET Framework 4.6.2/4.7.2 (#24)

* Remove < .NET 4.8, general cleanup

* Abstract

* Tango

* Banner

* Scan no more

* Common

* Application

* Access

* Filter-feeder

* Graffiti

* Paint-over

* Law and Order

* XOR-o

* Unused staircase

* Maybe

* Maybe not

* Delete this

* The word is "no"

* Emit

* Improper

* Aye aye

* Fence

* Barrier

* Monkey

* Pail

* Lines
This commit is contained in:
Matt Nadareski
2020-07-15 09:41:59 -07:00
committed by GitHub
parent 1a718a3915
commit 4e406604c2
82 changed files with 8975 additions and 11172 deletions

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using SabreTools.Library.Data;
using SabreTools.Library.DatItems;
@@ -24,7 +23,7 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="datFile">Parent DatFile to copy from</param>
public DosCenter(DatFile datFile)
: base(datFile, cloneHeader: false)
: base(datFile)
{
}
@@ -32,26 +31,22 @@ namespace SabreTools.Library.DatFiles
/// Parse a DOSCenter DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public override void ParseFile(
protected override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
int srcid,
int indexId,
// Miscellaneous
bool keep,
bool clean,
bool remUnicode)
bool keep)
{
// Open a file reader
Encoding enc = Utilities.GetEncoding(filename);
ClrMameProReader cmpr = new ClrMameProReader(Utilities.TryOpenRead(filename), enc);
cmpr.DosCenter = true;
Encoding enc = FileExtensions.GetEncoding(filename);
ClrMameProReader cmpr = new ClrMameProReader(FileExtensions.TryOpenRead(filename), enc)
{
DosCenter = true
};
while (!cmpr.EndOfStream)
{
@@ -71,7 +66,7 @@ namespace SabreTools.Library.DatFiles
// Sets
case "game":
ReadGame(cmpr, filename, sysid, srcid, clean, remUnicode);
ReadGame(cmpr, filename, indexId);
break;
default:
@@ -116,25 +111,25 @@ namespace SabreTools.Library.DatFiles
switch (itemKey)
{
case "name":
Name = (string.IsNullOrWhiteSpace(Name) ? itemVal : Name);
DatHeader.Name = (string.IsNullOrWhiteSpace(DatHeader.Name) ? itemVal : DatHeader.Name);
break;
case "description":
Description = (string.IsNullOrWhiteSpace(Description) ? itemVal : Description);
DatHeader.Description = (string.IsNullOrWhiteSpace(DatHeader.Description) ? itemVal : DatHeader.Description);
break;
case "dersion":
Version = (string.IsNullOrWhiteSpace(Version) ? itemVal : Version);
DatHeader.Version = (string.IsNullOrWhiteSpace(DatHeader.Version) ? itemVal : DatHeader.Version);
break;
case "date":
Date = (string.IsNullOrWhiteSpace(Date) ? itemVal : Date);
DatHeader.Date = (string.IsNullOrWhiteSpace(DatHeader.Date) ? itemVal : DatHeader.Date);
break;
case "author":
Author = (string.IsNullOrWhiteSpace(Author) ? itemVal : Author);
DatHeader.Author = (string.IsNullOrWhiteSpace(DatHeader.Author) ? itemVal : DatHeader.Author);
break;
case "homepage":
Homepage = (string.IsNullOrWhiteSpace(Homepage) ? itemVal : Homepage);
DatHeader.Homepage = (string.IsNullOrWhiteSpace(DatHeader.Homepage) ? itemVal : DatHeader.Homepage);
break;
case "comment":
Comment = (string.IsNullOrWhiteSpace(Comment) ? itemVal : Comment);
DatHeader.Comment = (string.IsNullOrWhiteSpace(DatHeader.Comment) ? itemVal : DatHeader.Comment);
break;
}
}
@@ -145,21 +140,13 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="cmpr">ClrMameProReader to use to parse the header</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="indexId">Index ID for the DAT</param>
private void ReadGame(
ClrMameProReader cmpr,
// Standard Dat parsing
string filename,
int sysid,
int srcid,
// Miscellaneous
bool clean,
bool remUnicode)
int indexId)
{
// Prepare all internal variables
bool containsItems = false;
@@ -208,14 +195,13 @@ namespace SabreTools.Library.DatFiles
containsItems = true;
// Create the proper DatItem based on the type
Rom item = Utilities.GetDatItem(ItemType.Rom) as Rom;
Rom item = DatItem.Create(ItemType.Rom) as Rom;
// Then populate it with information
item.CopyMachineInformation(machine);
item.SystemID = sysid;
item.System = filename;
item.SourceID = srcid;
item.IndexId = indexId;
item.IndexSource = filename;
// Loop through all of the attributes
foreach (var kvp in cmpr.Internal)
@@ -243,7 +229,7 @@ namespace SabreTools.Library.DatFiles
break;
case "crc":
item.CRC = Utilities.CleanHashData(attrVal, Constants.CRCLength);
item.CRC = attrVal;
break;
case "date":
item.Date = attrVal;
@@ -252,7 +238,7 @@ namespace SabreTools.Library.DatFiles
}
// Now process and add the rom
ParseAddHelper(item, clean, remUnicode);
ParseAddHelper(item);
}
}
@@ -261,15 +247,14 @@ namespace SabreTools.Library.DatFiles
{
Blank blank = new Blank()
{
SystemID = sysid,
System = filename,
SourceID = srcid,
IndexId = indexId,
IndexSource = filename,
};
blank.CopyMachineInformation(machine);
// Now process and add the rom
ParseAddHelper(blank, clean, remUnicode);
ParseAddHelper(blank);
}
}
@@ -285,7 +270,7 @@ namespace SabreTools.Library.DatFiles
try
{
Globals.Logger.User($"Opening file for writing: {outfile}");
FileStream fs = Utilities.TryCreate(outfile);
FileStream fs = FileExtensions.TryCreate(outfile);
// If we get back null for some reason, just log and return
if (fs == null)
@@ -294,8 +279,10 @@ namespace SabreTools.Library.DatFiles
return false;
}
ClrMameProWriter cmpw = new ClrMameProWriter(fs, new UTF8Encoding(false));
cmpw.Quotes = false;
ClrMameProWriter cmpw = new ClrMameProWriter(fs, new UTF8Encoding(false))
{
Quotes = false
};
// Write out the header
WriteHeader(cmpw);
@@ -329,7 +316,7 @@ namespace SabreTools.Library.DatFiles
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
WriteEndGame(cmpw, rom);
WriteEndGame(cmpw);
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
@@ -346,7 +333,9 @@ namespace SabreTools.Library.DatFiles
((Rom)rom).Size = Constants.SizeZero;
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
#if NET_FRAMEWORK
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
#endif
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
@@ -387,13 +376,13 @@ namespace SabreTools.Library.DatFiles
try
{
cmpw.WriteStartElement("DOSCenter");
cmpw.WriteStandalone("Name:", Name, false);
cmpw.WriteStandalone("Description:", Description, false);
cmpw.WriteStandalone("Version:", Version, false);
cmpw.WriteStandalone("Date:", Date, false);
cmpw.WriteStandalone("Author:", Author, false);
cmpw.WriteStandalone("Homepage:", Homepage, false);
cmpw.WriteStandalone("Comment:", Comment, false);
cmpw.WriteStandalone("Name:", DatHeader.Name, false);
cmpw.WriteStandalone("Description:", DatHeader.Description, false);
cmpw.WriteStandalone("Version:", DatHeader.Version, false);
cmpw.WriteStandalone("Date:", DatHeader.Date, false);
cmpw.WriteStandalone("Author:", DatHeader.Author, false);
cmpw.WriteStandalone("Homepage:", DatHeader.Homepage, false);
cmpw.WriteStandalone("Comment:", DatHeader.Comment, false);
cmpw.WriteEndElement();
cmpw.Flush();
@@ -422,7 +411,7 @@ namespace SabreTools.Library.DatFiles
// Build the state based on excluded fields
cmpw.WriteStartElement("game");
cmpw.WriteStandalone("name", $"{datItem.GetField(Field.MachineName, ExcludeFields)}.zip", true);
cmpw.WriteStandalone("name", $"{datItem.GetField(Field.MachineName, DatHeader.ExcludeFields)}.zip", true);
cmpw.Flush();
}
@@ -439,9 +428,8 @@ namespace SabreTools.Library.DatFiles
/// Write out Game end using the supplied StreamWriter
/// </summary>
/// <param name="cmpw">ClrMameProWriter to output to</param>
/// <param name="datItem">DatItem object to be output</param>
/// <returns>True if the data was written, false on error</returns>
private bool WriteEndGame(ClrMameProWriter cmpw, DatItem datItem)
private bool WriteEndGame(ClrMameProWriter cmpw)
{
try
{
@@ -483,12 +471,12 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom:
var rom = datItem as Rom;
cmpw.WriteStartElement("file");
cmpw.WriteAttributeString("name", datItem.GetField(Field.Name, ExcludeFields));
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
cmpw.WriteAttributeString("name", datItem.GetField(Field.Name, DatHeader.ExcludeFields));
if (!DatHeader.ExcludeFields[(int)Field.Size] && rom.Size != -1)
cmpw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, DatHeader.ExcludeFields)))
cmpw.WriteAttributeString("date", rom.Date);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, DatHeader.ExcludeFields)))
cmpw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
cmpw.WriteEndElement();
break;