Compound assignments and inheritdoc for DatFiles

This commit is contained in:
Matt Nadareski
2020-12-18 12:09:09 -08:00
parent 7bbdb22948
commit d741c8d4b2
17 changed files with 104 additions and 296 deletions

View File

@@ -12,8 +12,8 @@ namespace SabreTools.Core
/// <summary>
/// The current toolset version to be used by all child applications
/// </summary>
public readonly static string Version = $"v1.0.6";
//public readonly static string Version = $"v1.0.6-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
//public readonly static string Version = $"v1.0.6";
public readonly static string Version = $"v1.0.6-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
/// <summary>
/// Readies the console and outputs the header

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse an AttractMode DAT and return all found games within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -123,13 +117,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -37,13 +37,7 @@ namespace SabreTools.DatFiles.Formats
Quotes = quotes;
}
/// <summary>
/// Parse a ClrMamePro DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -139,49 +133,49 @@ namespace SabreTools.DatFiles.Formats
switch (itemKey)
{
case "name":
Header.Name = Header.Name ?? itemVal;
superdat = superdat || itemVal.Contains(" - SuperDAT");
Header.Name ??= itemVal;
superdat |= itemVal.Contains(" - SuperDAT");
if (keep && superdat)
Header.Type = Header.Type ?? "SuperDAT";
Header.Type ??= "SuperDAT";
break;
case "description":
Header.Description = Header.Description ?? itemVal;
Header.Description ??= itemVal;
break;
case "rootdir":
Header.RootDir = Header.RootDir ?? itemVal;
Header.RootDir ??= itemVal;
break;
case "category":
Header.Category = Header.Category ?? itemVal;
Header.Category ??= itemVal;
break;
case "version":
Header.Version = Header.Version ?? itemVal;
Header.Version ??= itemVal;
break;
case "date":
Header.Date = Header.Date ?? itemVal;
Header.Date ??= itemVal;
break;
case "author":
Header.Author = Header.Author ?? itemVal;
Header.Author ??= itemVal;
break;
case "email":
Header.Email = Header.Email ?? itemVal;
Header.Email ??= itemVal;
break;
case "homepage":
Header.Homepage = Header.Homepage ?? itemVal;
Header.Homepage ??= itemVal;
break;
case "url":
Header.Url = Header.Url ?? itemVal;
Header.Url ??= itemVal;
break;
case "comment":
Header.Comment = Header.Comment ?? itemVal;
Header.Comment ??= itemVal;
break;
case "header":
Header.HeaderSkipper = Header.HeaderSkipper ?? itemVal;
Header.HeaderSkipper ??= itemVal;
break;
case "type":
Header.Type = Header.Type ?? itemVal;
superdat = superdat || itemVal.Contains("SuperDAT");
Header.Type ??= itemVal;
superdat |= itemVal.Contains("SuperDAT");
break;
case "forcemerging":
if (Header.ForceMerging == MergingFlag.None)
@@ -442,13 +436,7 @@ namespace SabreTools.DatFiles.Formats
};
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// 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="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -119,25 +113,25 @@ namespace SabreTools.DatFiles.Formats
switch (itemKey)
{
case "name":
Header.Name = Header.Name ?? itemVal;
Header.Name ??= itemVal;
break;
case "description":
Header.Description = Header.Description ?? itemVal;
Header.Description ??= itemVal;
break;
case "dersion":
Header.Version = Header.Version ?? itemVal;
Header.Version ??= itemVal;
break;
case "date":
Header.Date = Header.Date ?? itemVal;
Header.Date ??= itemVal;
break;
case "author":
Header.Author = Header.Author ?? itemVal;
Header.Author ??= itemVal;
break;
case "homepage":
Header.Homepage = Header.Homepage ?? itemVal;
Header.Homepage ??= itemVal;
break;
case "comment":
Header.Comment = Header.Comment ?? itemVal;
Header.Comment ??= itemVal;
break;
}
}
@@ -268,13 +262,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse an Everdrive SMDB file and return all found games within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -114,13 +108,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -29,13 +29,7 @@ namespace SabreTools.DatFiles.Formats
_hash = hash;
}
/// <summary>
/// Parse a hashfile or SFV and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -115,13 +109,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a MAME Listrom DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
/// <remarks>
/// In a new style MAME listrom DAT, each game has the following format:
///
@@ -269,13 +263,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Disk, ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -190,13 +190,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a MAME XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -230,18 +224,18 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name)
{
case "mame":
Header.Name = Header.Name ?? xtr.GetAttribute("build");
Header.Description = Header.Description ?? Header.Name;
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo();
Header.MameConfig = Header.MameConfig ?? xtr.GetAttribute("mameconfig");
Header.Name ??= xtr.GetAttribute("build");
Header.Description ??= Header.Name;
Header.Debug ??= xtr.GetAttribute("debug").AsYesNo();
Header.MameConfig ??= xtr.GetAttribute("mameconfig");
xtr.Read();
break;
// Handle M1 DATs since they're 99% the same as a SL DAT
case "m1":
Header.Name = Header.Name ?? "M1";
Header.Description = Header.Description ?? "M1";
Header.Version = Header.Version ?? xtr.GetAttribute("version") ?? string.Empty;
Header.Name ??= "M1";
Header.Description ??= "M1";
Header.Version ??= xtr.GetAttribute("version") ?? string.Empty;
xtr.Read();
break;
@@ -1352,13 +1346,7 @@ namespace SabreTools.DatFiles.Formats
};
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -132,13 +132,7 @@ namespace SabreTools.DatFiles.Formats
_deprecated = deprecated;
}
/// <summary>
/// Parse a Logiqx XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -179,8 +173,8 @@ namespace SabreTools.DatFiles.Formats
{
// The datafile tag can have some attributes
case "datafile":
Header.Build = Header.Build ?? xtr.GetAttribute("build");
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo();
Header.Build ??= xtr.GetAttribute("build");
Header.Debug ??= xtr.GetAttribute("debug").AsYesNo();
xtr.Read();
break;
@@ -261,57 +255,57 @@ namespace SabreTools.DatFiles.Formats
{
case "name":
content = reader.ReadElementContentAsString();
Header.Name = Header.Name ?? content;
superdat = superdat || content.Contains(" - SuperDAT");
Header.Name ??= content;
superdat |= content.Contains(" - SuperDAT");
if (keep && superdat)
{
Header.Type = Header.Type ?? "SuperDAT";
Header.Type ??= "SuperDAT";
}
break;
case "description":
content = reader.ReadElementContentAsString();
Header.Description = Header.Description ?? content;
Header.Description ??= content;
break;
case "rootdir": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString();
Header.RootDir = Header.RootDir ?? content;
Header.RootDir ??= content;
break;
case "category":
content = reader.ReadElementContentAsString();
Header.Category = Header.Category ?? content;
Header.Category ??= content;
break;
case "version":
content = reader.ReadElementContentAsString();
Header.Version = Header.Version ?? content;
Header.Version ??= content;
break;
case "date":
content = reader.ReadElementContentAsString();
Header.Date = Header.Date ?? content.Replace(".", "/");
Header.Date ??= content.Replace(".", "/");
break;
case "author":
content = reader.ReadElementContentAsString();
Header.Author = Header.Author ?? content;
Header.Author ??= content;
break;
case "email":
content = reader.ReadElementContentAsString();
Header.Email = Header.Email ?? content;
Header.Email ??= content;
break;
case "homepage":
content = reader.ReadElementContentAsString();
Header.Homepage = Header.Homepage ?? content;
Header.Homepage ??= content;
break;
case "url":
content = reader.ReadElementContentAsString();
Header.Url = Header.Url ?? content;
Header.Url ??= content;
break;
case "comment":
@@ -321,8 +315,8 @@ namespace SabreTools.DatFiles.Formats
case "type": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString();
Header.Type = Header.Type ?? content;
superdat = superdat || content.Contains("SuperDAT");
Header.Type ??= content;
superdat |= content.Contains("SuperDAT");
break;
case "clrmamepro":
@@ -781,13 +775,7 @@ namespace SabreTools.DatFiles.Formats
};
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -21,26 +21,14 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a Missfile and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// There is no consistent way to parse a missfile...
throw new NotImplementedException();
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -26,13 +26,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse an OfflineList XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
@@ -132,34 +126,34 @@ namespace SabreTools.DatFiles.Formats
{
case "datname":
content = reader.ReadElementContentAsString();
Header.Name = Header.Name ?? content;
superdat = superdat || content.Contains(" - SuperDAT");
Header.Name ??= content;
superdat |= content.Contains(" - SuperDAT");
if (keep && superdat)
{
Header.Type = Header.Type ?? "SuperDAT";
Header.Type ??= "SuperDAT";
}
break;
case "datversion":
content = reader.ReadElementContentAsString();
Header.Version = Header.Version ?? content;
Header.Version ??= content;
break;
case "system":
content = reader.ReadElementContentAsString();
Header.System = Header.System ?? content;
Header.System ??= content;
break;
// TODO: Int32?
case "screenshotswidth":
content = reader.ReadElementContentAsString();
Header.ScreenshotsWidth = Header.ScreenshotsWidth ?? content;
Header.ScreenshotsWidth ??= content;
break;
// TODO: Int32?
case "screenshotsheight":
content = reader.ReadElementContentAsString();
Header.ScreenshotsHeight = Header.ScreenshotsHeight ?? content;
Header.ScreenshotsHeight ??= content;
break;
case "infos":
@@ -194,7 +188,7 @@ namespace SabreTools.DatFiles.Formats
case "romtitle":
content = reader.ReadElementContentAsString();
Header.RomTitle = Header.RomTitle ?? content;
Header.RomTitle ??= content;
break;
default:
@@ -674,13 +668,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -40,13 +40,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a openMSX softawre list XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -80,9 +74,9 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name)
{
case "softwaredb":
Header.Name = Header.Name ?? "openMSX Software List";
Header.Description = Header.Description ?? Header.Name;
Header.Date = Header.Date ?? xtr.GetAttribute("timestamp");
Header.Name ??= "openMSX Software List";
Header.Description ??= Header.Name;
Header.Date ??= xtr.GetAttribute("timestamp");
xtr.Read();
break;
@@ -542,13 +536,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a RomCenter DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all intenral variables
@@ -130,37 +124,37 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant())
{
case "author":
Header.Author = Header.Author ?? kvp?.Value;
Header.Author ??= kvp?.Value;
reader.ReadNextLine();
break;
case "version":
Header.Version = Header.Version ?? kvp?.Value;
Header.Version ??= kvp?.Value;
reader.ReadNextLine();
break;
case "email":
Header.Email = Header.Email ?? kvp?.Value;
Header.Email ??= kvp?.Value;
reader.ReadNextLine();
break;
case "homepage":
Header.Homepage = Header.Homepage ?? kvp?.Value;
Header.Homepage ??= kvp?.Value;
reader.ReadNextLine();
break;
case "url":
Header.Url = Header.Url ?? kvp?.Value;
Header.Url ??= kvp?.Value;
reader.ReadNextLine();
break;
case "date":
Header.Date = Header.Date ?? kvp?.Value;
Header.Date ??= kvp?.Value;
reader.ReadNextLine();
break;
case "comment":
Header.Comment = Header.Comment ?? kvp?.Value;
Header.Comment ??= kvp?.Value;
reader.ReadNextLine();
break;
@@ -205,12 +199,12 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant())
{
case "version":
Header.RomCenterVersion = Header.RomCenterVersion ?? kvp?.Value;
Header.RomCenterVersion ??= kvp?.Value;
reader.ReadNextLine();
break;
case "plugin":
Header.System = Header.System ?? kvp?.Value;
Header.System ??= kvp?.Value;
reader.ReadNextLine();
break;
@@ -269,12 +263,12 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant())
{
case "refname":
Header.Name = Header.Name ?? kvp?.Value;
Header.Name ??= kvp?.Value;
reader.ReadNextLine();
break;
case "version":
Header.Description = Header.Description ?? kvp?.Value;
Header.Description ??= kvp?.Value;
reader.ReadNextLine();
break;
@@ -373,13 +367,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse a reference JSON DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -332,13 +326,7 @@ namespace SabreTools.DatFiles.Formats
}
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -24,13 +24,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse an SabreDat XML DAT and return all found directories and files within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -186,13 +180,7 @@ namespace SabreTools.DatFiles.Formats
}
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -31,13 +31,7 @@ namespace SabreTools.DatFiles.Formats
_delim = delim;
}
/// <summary>
/// Parse a character-separated value DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Open a file reader
@@ -131,13 +125,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom };
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try

View File

@@ -90,13 +90,7 @@ namespace SabreTools.DatFiles.Formats
{
}
/// <summary>
/// Parse an SofwareList XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</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="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{
// Prepare all internal variables
@@ -130,8 +124,8 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name)
{
case "softwarelist":
Header.Name = Header.Name ?? xtr.GetAttribute("name") ?? string.Empty;
Header.Description = Header.Description ?? xtr.GetAttribute("description") ?? string.Empty;
Header.Name ??= xtr.GetAttribute("name") ?? string.Empty;
Header.Description ??= xtr.GetAttribute("description") ?? string.Empty;
xtr.Read();
break;
@@ -590,13 +584,7 @@ namespace SabreTools.DatFiles.Formats
};
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
/// <inheritdoc/>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try