More work on Romba support, add special string replacement in MissFile output (undocumented externally)

This commit is contained in:
Matt Nadareski
2016-05-22 20:42:04 -07:00
parent b1554445c5
commit eb0b00724b
2 changed files with 8 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text.RegularExpressions;
using SabreTools.Helper; using SabreTools.Helper;
using DamienG.Security.Cryptography; using DamienG.Security.Cryptography;
@@ -208,6 +209,7 @@ namespace SabreTools
/// Process the file, folder, or list of some combination into a DAT file /// Process the file, folder, or list of some combination into a DAT file
/// </summary> /// </summary>
/// <returns>True if the DAT could be created, false otherwise</returns> /// <returns>True if the DAT could be created, false otherwise</returns>
/// <remarks>Try to get the hashing multithreaded (either on a per-hash or per-file level)</remarks>
public bool Start() public bool Start()
{ {
// Create an output dictionary for all found items // 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) // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
if (_datdata.Romba) if (_datdata.Romba)
{ {
string datum = Path.GetFileNameWithoutExtension(item); string datum = Path.GetFileNameWithoutExtension(item).ToLowerInvariant();
// Check if the name is the right length // 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 + "'"); _logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'");
return; return;

View File

@@ -277,6 +277,10 @@ namespace SabreTools.Helper
string pre = datdata.Prefix + (datdata.Quotes ? "\"" : ""); string pre = datdata.Prefix + (datdata.Quotes ? "\"" : "");
string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; 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 we're in Romba mode, the state is consistent
if (datdata.Romba) if (datdata.Romba)
{ {