mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
More work on Romba support, add special string replacement in MissFile output (undocumented externally)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user