From eb0b00724b6d130c81ec103bebf4489fda1547af Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 22 May 2016 20:42:04 -0700 Subject: [PATCH] More work on Romba support, add special string replacement in MissFile output (undocumented externally) --- DATFromDir/DATFromDir.cs | 6 ++++-- SabreHelper/Output.cs | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs index 6c4cf797..2a736248 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATFromDir/DATFromDir.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.IO; using System.Security.Cryptography; +using System.Text.RegularExpressions; using SabreTools.Helper; using DamienG.Security.Cryptography; @@ -208,6 +209,7 @@ namespace SabreTools /// Process the file, folder, or list of some combination into a DAT file /// /// True if the DAT could be created, false otherwise + /// Try to get the hashing multithreaded (either on a per-hash or per-file level) public bool Start() { // Create an output dictionary for all found items @@ -377,10 +379,10 @@ namespace SabreTools // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes) if (_datdata.Romba) { - string datum = Path.GetFileNameWithoutExtension(item); + string datum = Path.GetFileNameWithoutExtension(item).ToLowerInvariant(); // Check if the name is the right length - if (datum.Length != 40) + if (!Regex.IsMatch(datum, @"^[0-9a-f]{40}")) { _logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'"); return; diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index c1e115a5..46086a97 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -277,6 +277,10 @@ namespace SabreTools.Helper string pre = datdata.Prefix + (datdata.Quotes ? "\"" : ""); string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; + // Check for special strings in prefix and postfix + pre = pre.Replace("%crc%", rom.CRC).Replace("%md5%", rom.MD5).Replace("%sha1%", rom.SHA1).Replace("%size%", rom.Size.ToString()); + post = post.Replace("%crc%", rom.CRC).Replace("%md5%", rom.MD5).Replace("%sha1%", rom.SHA1).Replace("%size%", rom.Size.ToString()); + // If we're in Romba mode, the state is consistent if (datdata.Romba) {