[DatTools] Add remove extension to missfile

This change also makes PopulateUserDataParallel default for now.
This commit is contained in:
Matt Nadareski
2016-09-12 14:52:46 -07:00
parent 121de22ab5
commit 254495c5fc
6 changed files with 44 additions and 6 deletions

View File

@@ -198,6 +198,7 @@ namespace SabreTools.Helper
helptext.Add(" -q, --quotes Put double-quotes around each item"); helptext.Add(" -q, --quotes Put double-quotes around each item");
helptext.Add(" -ae=, --add-ext= Add an extension to each item"); helptext.Add(" -ae=, --add-ext= Add an extension to each item");
helptext.Add(" -re=, --rep-ext= Replace all extensions with specified"); helptext.Add(" -re=, --rep-ext= Replace all extensions with specified");
helptext.Add(" -rme, --rem-ext Remove all extensions from each item");
helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)"); helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)");
helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format"); helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format");
helptext.Add(" -csv, --csv Output in Comma-Separated Value format"); helptext.Add(" -csv, --csv Output in Comma-Separated Value format");

View File

@@ -329,6 +329,7 @@ namespace SabreTools.Helper
public bool Quotes; public bool Quotes;
public string RepExt; public string RepExt;
public string AddExt; public string AddExt;
public bool RemExt;
public bool GameName; public bool GameName;
public bool Romba; public bool Romba;
public bool? XSV; // true for tab-deliminated output, false for comma-deliminated output public bool? XSV; // true for tab-deliminated output, false for comma-deliminated output

View File

@@ -497,6 +497,14 @@ Options:
-post=, --postfix= Set postfix for all lines -post=, --postfix= Set postfix for all lines
Set a generic postfix to be appended to all outputted lines Set a generic postfix to be appended to all outputted lines
Both prefix and postfix can use one of the following special strings:
- %game% - Replaced with the Game/Machine name
- %name% - Replaced with the Rom name
- %crc% - Replaced with the CRC
- %md5% - Replaced with the MD5
- %sha1% - Replaced with the SHA-1
- %size% - Replaced with the size
-q, --quotes Put double-quotes around each item -q, --quotes Put double-quotes around each item
This quotes only the item and not the prefix and postfix This quotes only the item and not the prefix and postfix
@@ -506,6 +514,9 @@ Options:
-re=, --rep-ext= Replace all extensions with specified -re=, --rep-ext= Replace all extensions with specified
When an extension exists, replace it with the provided instead When an extension exists, replace it with the provided instead
-rme, --rem-ext Remove all extensions from all items
For each item, the extension is removed
-ro, --romba Output in Romba format (requires SHA-1) -ro, --romba Output in Romba format (requires SHA-1)
Instead of outputting the game or rom name, output the SHA-1 of the files Instead of outputting the game or rom name, output the SHA-1 of the files
instead. This requires the source DAT to have SHA-1 hashes. instead. This requires the source DAT to have SHA-1 hashes.

View File

@@ -2496,9 +2496,9 @@ namespace SabreTools.Helper
// Create a dictionary of all ROMs from the input DATs // Create a dictionary of all ROMs from the input DATs
Dat userData; Dat userData;
List<Dat> datHeaders = PopulateUserData(newInputFileNames, inplace, clean, softlist, List<Dat> datHeaders = PopulateUserDataParallel(newInputFileNames, inplace, clean, softlist,
outputDirectory, datdata, out userData, gamename, romname, romtype, sgt, slt, seq, outputDirectory, datdata, out userData, gamename, romname, romtype, sgt, slt, seq,
crc, md5, sha1, nodump, trim, single, root, logger); crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, logger);
// Modify the Dictionary if necessary and output the results // Modify the Dictionary if necessary and output the results
if (diff != 0 && cascade == null) if (diff != 0 && cascade == null)
@@ -3129,8 +3129,20 @@ namespace SabreTools.Helper
string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix;
// Check for special strings in prefix and postfix // Check for special strings in prefix and postfix
pre = pre.Replace("%crc%", rom.HashData.CRC).Replace("%md5%", rom.HashData.MD5).Replace("%sha1%", rom.HashData.SHA1).Replace("%size%", rom.HashData.Size.ToString()); pre = pre
post = post.Replace("%crc%", rom.HashData.CRC).Replace("%md5%", rom.HashData.MD5).Replace("%sha1%", rom.HashData.SHA1).Replace("%size%", rom.HashData.Size.ToString()); .Replace("%game%", rom.Machine.Name)
.Replace("%name%", rom.Name)
.Replace("%crc%", rom.HashData.CRC)
.Replace("%md5%", rom.HashData.MD5)
.Replace("%sha1%", rom.HashData.SHA1)
.Replace("%size%", rom.HashData.Size.ToString());
post = post
.Replace("%game%", rom.Machine.Name)
.Replace("%name%", rom.Name)
.Replace("%crc%", rom.HashData.CRC)
.Replace("%md5%", rom.HashData.MD5)
.Replace("%sha1%", rom.HashData.SHA1)
.Replace("%size%", rom.HashData.Size.ToString());
// If we're in Romba mode, the state is consistent // If we're in Romba mode, the state is consistent
if (datdata.Romba) if (datdata.Romba)
@@ -3163,8 +3175,13 @@ namespace SabreTools.Helper
else else
{ {
string name = (datdata.UseGame ? rom.Machine.Name : rom.Name); string name = (datdata.UseGame ? rom.Machine.Name : rom.Name);
if (datdata.RepExt != "") if (datdata.RepExt != "" || datdata.RemExt)
{ {
if (datdata.RemExt)
{
datdata.RepExt = "";
}
string dir = Path.GetDirectoryName(name); string dir = Path.GetDirectoryName(name);
dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir); dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir);
name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + datdata.RepExt); name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + datdata.RepExt);

View File

@@ -101,6 +101,7 @@ namespace SabreTools
/// <param name="quotes">Add quotes to each item</param> /// <param name="quotes">Add quotes to each item</param>
/// <param name="repext">Replace all extensions with another</param> /// <param name="repext">Replace all extensions with another</param>
/// <param name="addext">Add an extension to all items</param> /// <param name="addext">Add an extension to all items</param>
/// <param name="remext">Remove all extensions</param>
/// <param name="datprefix">Add the dat name as a directory prefix</param> /// <param name="datprefix">Add the dat name as a directory prefix</param>
/// <param name="romba">Output files in romba format</param> /// <param name="romba">Output files in romba format</param>
/// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param> /// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param>
@@ -161,6 +162,7 @@ namespace SabreTools
bool quotes, bool quotes,
string repext, string repext,
string addext, string addext,
bool remext,
bool datprefix, bool datprefix,
bool romba, bool romba,
bool? tsv, bool? tsv,
@@ -311,6 +313,7 @@ namespace SabreTools
Quotes = quotes, Quotes = quotes,
RepExt = repext, RepExt = repext,
AddExt = addext, AddExt = addext,
RemExt = remext,
GameName = datprefix, GameName = datprefix,
Romba = romba, Romba = romba,
XSV = tsv, XSV = tsv,

View File

@@ -105,6 +105,7 @@ namespace SabreTools
old = false, old = false,
quotes = false, quotes = false,
rem = false, rem = false,
remext = false,
romba = false, romba = false,
single = false, single = false,
softlist = false, softlist = false,
@@ -367,6 +368,10 @@ namespace SabreTools
case "--remove": case "--remove":
rem = true; rem = true;
break; break;
case "-rme":
case "--rem-ext":
remext = true;
break;
case "-ro": case "-ro":
case "--romba": case "--romba":
romba = true; romba = true;
@@ -670,7 +675,7 @@ namespace SabreTools
{ {
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header, InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix, superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname, postfix, quotes, repext, addext, remext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism); romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism);
} }