mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix oversights in hashfiles
- Allows for multiple spaces between filename and hash - Allows for paths in names to be counted as machine names
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
@@ -43,7 +44,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
string line = sr.ReadLine();
|
||||
|
||||
// Split the line and get the name and hash
|
||||
string[] split = line.Split(' ');
|
||||
string[] split = Regex.Replace(line, @"\s+", " ").Split(' ');
|
||||
string name = string.Empty;
|
||||
string hash = string.Empty;
|
||||
|
||||
@@ -60,6 +61,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
hash = split[0];
|
||||
}
|
||||
|
||||
// If the name contains a path, use that path as the machine
|
||||
string machine = Path.GetFileNameWithoutExtension(filename);
|
||||
if (name.Contains('/'))
|
||||
{
|
||||
split = name.Split('/');
|
||||
machine = split[0];
|
||||
name = name.Substring(machine.Length + 1);
|
||||
}
|
||||
else if (name.Contains('\\'))
|
||||
{
|
||||
split = name.Split('\\');
|
||||
machine = split[0];
|
||||
name = name.Substring(machine.Length + 1);
|
||||
}
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Name = name,
|
||||
@@ -75,7 +91,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(filename),
|
||||
Name = machine,
|
||||
},
|
||||
|
||||
Source = new Source
|
||||
|
||||
Reference in New Issue
Block a user