mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatTools] Add external flag for software list name usage
This commit is contained in:
@@ -163,7 +163,7 @@ Options:
|
|||||||
Supported values are:
|
Supported values are:
|
||||||
None, Zip, Unzip
|
None, Zip, Unzip
|
||||||
-clean Clean game names according to WoD standards
|
-clean Clean game names according to WoD standards
|
||||||
-sl Use Software List name instead of description
|
-sl, --softlist Use Software List name instead of description
|
||||||
-trim Trim file names to fit NTFS length
|
-trim Trim file names to fit NTFS length
|
||||||
-rd=, --root-dir= Set the root directory for calc
|
-rd=, --root-dir= Set the root directory for calc
|
||||||
-si, --single All game names replaced by '!'
|
-si, --single All game names replaced by '!'
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</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="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||||
/// <returns>DatData object representing the read-in data</returns>
|
/// <returns>DatData object representing the read-in data</returns>
|
||||||
public static Dat Parse(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep = false, bool clean = false, bool sl = false)
|
public static Dat Parse(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep = false, bool clean = false, bool softlist = false)
|
||||||
{
|
{
|
||||||
// If the output filename isn't set already, get the internal filename
|
// If the output filename isn't set already, get the internal filename
|
||||||
if (String.IsNullOrEmpty(datdata.FileName))
|
if (String.IsNullOrEmpty(datdata.FileName))
|
||||||
@@ -106,7 +106,7 @@ namespace SabreTools.Helper
|
|||||||
return ParseRC(filename, sysid, srcid, datdata, logger, clean);
|
return ParseRC(filename, sysid, srcid, datdata, logger, clean);
|
||||||
case OutputFormat.SabreDat:
|
case OutputFormat.SabreDat:
|
||||||
case OutputFormat.Xml:
|
case OutputFormat.Xml:
|
||||||
return ParseXML(filename, sysid, srcid, datdata, logger, keep, clean, sl);
|
return ParseXML(filename, sysid, srcid, datdata, logger, keep, clean, softlist);
|
||||||
default:
|
default:
|
||||||
return datdata;
|
return datdata;
|
||||||
}
|
}
|
||||||
@@ -619,9 +619,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="logger">Logger object for console and/or file output</param>
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</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="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||||
/// <param name="sl">True if SL XML names should be kept, false otherwise (default)</param>
|
/// <param name="softlist">True if SL XML names should be kept, false otherwise (default)</param>
|
||||||
/// <returns>DatData object representing the read-in data</returns>
|
/// <returns>DatData object representing the read-in data</returns>
|
||||||
public static Dat ParseXML(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean, bool sl)
|
public static Dat ParseXML(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean, bool softlist)
|
||||||
{
|
{
|
||||||
// Prepare all internal variables
|
// Prepare all internal variables
|
||||||
XmlReader subreader, headreader, flagreader;
|
XmlReader subreader, headreader, flagreader;
|
||||||
@@ -957,7 +957,7 @@ namespace SabreTools.Helper
|
|||||||
// If we have a subtree, add what is possible
|
// If we have a subtree, add what is possible
|
||||||
if (subreader != null)
|
if (subreader != null)
|
||||||
{
|
{
|
||||||
if (!sl && temptype == "software" && subreader.ReadToFollowing("description"))
|
if (!softlist && temptype == "software" && subreader.ReadToFollowing("description"))
|
||||||
{
|
{
|
||||||
tempname = subreader.ReadElementContentAsString();
|
tempname = subreader.ReadElementContentAsString();
|
||||||
tempname = tempname.Replace('/', '_').Replace("\"", "''");
|
tempname = tempname.Replace('/', '_').Replace("\"", "''");
|
||||||
@@ -1512,6 +1512,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param>
|
/// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param>
|
||||||
/// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param>
|
/// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param>
|
||||||
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
|
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
|
||||||
|
/// <param name="softlist">True to allow SL DATs to have game names used instead of descriptions, false otherwise (default)</param>
|
||||||
/// <param name="gamename">Name of the game to match (can use asterisk-partials)</param>
|
/// <param name="gamename">Name of the game to match (can use asterisk-partials)</param>
|
||||||
/// <param name="romname">Name of the rom to match (can use asterisk-partials)</param>
|
/// <param name="romname">Name of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="romtype">Type of the rom to match</param>
|
/// <param name="romtype">Type of the rom to match</param>
|
||||||
@@ -1527,7 +1528,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="root">String representing root directory to compare against for length calculation</param>
|
/// <param name="root">String representing root directory to compare against for length calculation</param>
|
||||||
/// <param name="logger">Logging object for console and file output</param>
|
/// <param name="logger">Logging object for console and file output</param>
|
||||||
public static void Update(List<string> inputFileNames, Dat datdata, string outputDirectory, bool merge, bool diff, bool cascade, bool inplace,
|
public static void Update(List<string> inputFileNames, Dat datdata, string outputDirectory, bool merge, bool diff, bool cascade, bool inplace,
|
||||||
bool bare, bool clean, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5,
|
bool bare, bool clean, bool softlist, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5,
|
||||||
string sha1, bool? nodump, bool trim, bool single, string root, Logger logger)
|
string sha1, bool? nodump, bool trim, bool single, string root, Logger logger)
|
||||||
{
|
{
|
||||||
// If we're in merging or diffing mode, use the full list of inputs
|
// If we're in merging or diffing mode, use the full list of inputs
|
||||||
@@ -1575,7 +1576,7 @@ namespace SabreTools.Helper
|
|||||||
// Create a dictionary of all ROMs from the input DATs
|
// Create a dictionary of all ROMs from the input DATs
|
||||||
datdata.FileName = datdata.Description;
|
datdata.FileName = datdata.Description;
|
||||||
Dat userData;
|
Dat userData;
|
||||||
List<Dat> datHeaders = PopulateUserData(newInputFileNames, inplace, clean, outputDirectory, datdata, out userData, logger);
|
List<Dat> datHeaders = PopulateUserData(newInputFileNames, inplace, clean, softlist, outputDirectory, datdata, out userData, logger);
|
||||||
|
|
||||||
// If we want to filter, apply it to the userData now
|
// If we want to filter, apply it to the userData now
|
||||||
userData = Filter(userData, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger);
|
userData = Filter(userData, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger);
|
||||||
@@ -1612,7 +1613,7 @@ namespace SabreTools.Helper
|
|||||||
if (File.Exists(inputFileName))
|
if (File.Exists(inputFileName))
|
||||||
{
|
{
|
||||||
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
|
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
|
||||||
datdata = Parse(inputFileName, 0, 0, datdata, logger, true, clean);
|
datdata = Parse(inputFileName, 0, 0, datdata, logger, true, clean, softlist);
|
||||||
datdata = Filter(datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger);
|
datdata = Filter(datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger);
|
||||||
|
|
||||||
// If the extension matches, append ".new" to the filename
|
// If the extension matches, append ".new" to the filename
|
||||||
@@ -1669,7 +1670,7 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userData">Output user DatData object to output</param>
|
/// <param name="userData">Output user DatData object to output</param>
|
||||||
/// <returns>List of DatData objects representing headers</returns>
|
/// <returns>List of DatData objects representing headers</returns>
|
||||||
private static List<Dat> PopulateUserData(List<string> inputs, bool inplace, bool clean, string outdir, Dat inputDat, out Dat userData, Logger logger)
|
private static List<Dat> PopulateUserData(List<string> inputs, bool inplace, bool clean, bool softlist, string outdir, Dat inputDat, out Dat userData, Logger logger)
|
||||||
{
|
{
|
||||||
List<Dat> datHeaders = new List<Dat>();
|
List<Dat> datHeaders = new List<Dat>();
|
||||||
|
|
||||||
@@ -1682,7 +1683,7 @@ namespace SabreTools.Helper
|
|||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
logger.User("Adding DAT: " + input.Split('¬')[0]);
|
logger.User("Adding DAT: " + input.Split('¬')[0]);
|
||||||
userData = Parse(input.Split('¬')[0], i, 0, userData, logger, true, clean);
|
userData = Parse(input.Split('¬')[0], i, 0, userData, logger, true, clean, softlist);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// If we are in inplace mode or redirecting output, save the DAT data
|
// If we are in inplace mode or redirecting output, save the DAT data
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ namespace SabreTools
|
|||||||
/// /* Output DAT info */
|
/// /* Output DAT info */
|
||||||
/// <param name="outdir">Optional param for output directory</param>
|
/// <param name="outdir">Optional param for output directory</param>
|
||||||
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
|
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
|
||||||
|
/// <param name="softlist">True to allow SL DATs to have game names used instead of descriptions, false otherwise (default)</param>
|
||||||
/// <param name="dedup">True to dedupe the roms in the DAT, false otherwise (default)</param>
|
/// <param name="dedup">True to dedupe the roms in the DAT, false otherwise (default)</param>
|
||||||
private static void InitUpdate(List<string> inputs,
|
private static void InitUpdate(List<string> inputs,
|
||||||
/* Normal DAT header info */
|
/* Normal DAT header info */
|
||||||
@@ -194,6 +195,7 @@ namespace SabreTools
|
|||||||
/* Output DAT info */
|
/* Output DAT info */
|
||||||
string outdir,
|
string outdir,
|
||||||
bool clean,
|
bool clean,
|
||||||
|
bool softlist,
|
||||||
bool dedup)
|
bool dedup)
|
||||||
{
|
{
|
||||||
// Set the special flags
|
// Set the special flags
|
||||||
@@ -314,31 +316,31 @@ namespace SabreTools
|
|||||||
if (outputCMP)
|
if (outputCMP)
|
||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.ClrMamePro;
|
userInputDat.OutputFormat = OutputFormat.ClrMamePro;
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
if (outputMiss)
|
if (outputMiss)
|
||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.MissFile;
|
userInputDat.OutputFormat = OutputFormat.MissFile;
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
if (outputRC)
|
if (outputRC)
|
||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.RomCenter;
|
userInputDat.OutputFormat = OutputFormat.RomCenter;
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
if (outputSD)
|
if (outputSD)
|
||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.SabreDat;
|
userInputDat.OutputFormat = OutputFormat.SabreDat;
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
if (outputXML)
|
if (outputXML)
|
||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.Xml;
|
userInputDat.OutputFormat = OutputFormat.Xml;
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
if (!outputCMP && !outputMiss && !outputRC && !outputSD && !outputXML)
|
if (!outputCMP && !outputMiss && !outputRC && !outputSD && !outputXML)
|
||||||
@@ -347,7 +349,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
userInputDat.OutputFormat = OutputFormat.Xml;
|
userInputDat.OutputFormat = OutputFormat.Xml;
|
||||||
}
|
}
|
||||||
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean,
|
DatTools.Update(inputs, userInputDat, outdir, merge, diff, cascade, inplace, bare, clean, softlist,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, _logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ namespace SabreTools
|
|||||||
rem = false,
|
rem = false,
|
||||||
romba = false,
|
romba = false,
|
||||||
single = false,
|
single = false,
|
||||||
|
softlist = false,
|
||||||
stats = false,
|
stats = false,
|
||||||
superdat = false,
|
superdat = false,
|
||||||
trim = false,
|
trim = false,
|
||||||
@@ -349,6 +350,10 @@ namespace SabreTools
|
|||||||
case "--single":
|
case "--single":
|
||||||
single = true;
|
single = true;
|
||||||
break;
|
break;
|
||||||
|
case "-sl":
|
||||||
|
case "--softlist":
|
||||||
|
softlist = true;
|
||||||
|
break;
|
||||||
case "-st":
|
case "-st":
|
||||||
case "--stats":
|
case "--stats":
|
||||||
stats = true;
|
stats = true;
|
||||||
@@ -638,7 +643,7 @@ namespace SabreTools
|
|||||||
InitUpdate(inputs, filename, name, description, category, version, date, author, email, homepage, url, comment, header,
|
InitUpdate(inputs, filename, name, description, category, version, date, author, email, homepage, url, comment, header,
|
||||||
superdat, forcemerge, forcend, forcepack, outputCMP, outputMiss, outputRC, outputSD, outputXML, usegame, prefix,
|
superdat, forcemerge, forcend, forcepack, outputCMP, outputMiss, outputRC, outputSD, outputXML, usegame, prefix,
|
||||||
postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diff, cascade, inplace, bare, gamename, romname,
|
postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diff, cascade, inplace, bare, gamename, romname,
|
||||||
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, dedup);
|
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a source or system
|
// Add a source or system
|
||||||
|
|||||||
Reference in New Issue
Block a user