diff --git a/SabreTools.DatFiles/Formats/Hashfile.cs b/SabreTools.DatFiles/Formats/Hashfile.cs index 561667b1..23c0f3c6 100644 --- a/SabreTools.DatFiles/Formats/Hashfile.cs +++ b/SabreTools.DatFiles/Formats/Hashfile.cs @@ -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