diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
index 6f6fdc8c..4cab7321 100644
--- a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
+++ b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
@@ -143,7 +143,7 @@ namespace SabreTools.Helper.Dats
logger.User("Checking hash '" + hash + "'");
// Get the extension path for the hash
- string subpath = Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash.Substring(4, 2), hash.Substring(6, 2), hash + ".gz");
+ string subpath = Style.GetRombaPath(hash);
// Find the first depot that includes the hash
string foundpath = null;
diff --git a/SabreTools.Helper/Tools/ArchiveTools.cs b/SabreTools.Helper/Tools/ArchiveTools.cs
index 796f8c83..3a0183a1 100644
--- a/SabreTools.Helper/Tools/ArchiveTools.cs
+++ b/SabreTools.Helper/Tools/ArchiveTools.cs
@@ -1330,7 +1330,18 @@ namespace SabreTools.Helper.Tools
Rom rom = FileTools.GetFileInfo(input, logger);
// Get the output file name
- string outfile = Path.Combine(outDir, rom.SHA1 + ".gz");
+ string outfile = null;
+
+ // If we have a romba output, add the romba path
+ if (romba)
+ {
+ outfile = Path.Combine(outDir, Style.GetRombaPath(rom.SHA1));
+ }
+ // Otherwise, we're just rebuilding to the main directory
+ else
+ {
+ outfile = Path.Combine(outDir, rom.SHA1 + ".gz");
+ }
// If the output file exists, don't try to write again
if (!File.Exists(outfile))
@@ -1373,12 +1384,6 @@ namespace SabreTools.Helper.Tools
inputStream.Dispose();
}
- // If we're in romba mode, create the subfolder and move the file
- if (romba)
- {
- FileTools.MoveToRombaFolder(rom, outDir, outfile, logger);
- }
-
return true;
}
diff --git a/SabreTools.Helper/Tools/FileTools.cs b/SabreTools.Helper/Tools/FileTools.cs
index 77c1944b..25be7119 100644
--- a/SabreTools.Helper/Tools/FileTools.cs
+++ b/SabreTools.Helper/Tools/FileTools.cs
@@ -417,18 +417,6 @@ namespace SabreTools.Helper.Tools
return outputs;
}
- ///
- /// Get the romba path for a file based on the rom's SHA-1
- ///
- /// Rom to get the sha1 from
- /// Base output folder
- /// Formatted path string to use
- public static string GetRombaPath(Rom rom, string baseOutDir)
- {
- string subfolder = Path.Combine(rom.SHA1.Substring(0, 2), rom.SHA1.Substring(2, 2), rom.SHA1.Substring(4, 2), rom.SHA1.Substring(6, 2));
- return Path.Combine(baseOutDir, subfolder);
- }
-
///
/// Get the XmlTextReader associated with a file, if possible
///
@@ -458,32 +446,6 @@ namespace SabreTools.Helper.Tools
return xtr;
}
- ///
- /// Move a file to a named, Romba-style subdirectory
- ///
- /// Rom to get the sha1 from
- /// Base output folder
- /// Name of the file to be moved
- /// Logger object for file and console output
- public static void MoveToRombaFolder(Rom rom, string baseOutDir, string filename, Logger logger)
- {
- string outDir = GetRombaPath(rom, baseOutDir);
- if (!Directory.Exists(outDir))
- {
- Directory.CreateDirectory(outDir);
- }
-
- try
- {
- File.Move(filename, Path.Combine(outDir, Path.GetFileName(filename)));
- }
- catch (Exception ex)
- {
- logger.Warning(ex.ToString());
- File.Delete(filename);
- }
- }
-
///
/// Detect and replace header(s) to the given file
///
diff --git a/SabreTools.Helper/Tools/Style.cs b/SabreTools.Helper/Tools/Style.cs
index b81bcc97..b7e21800 100644
--- a/SabreTools.Helper/Tools/Style.cs
+++ b/SabreTools.Helper/Tools/Style.cs
@@ -387,6 +387,22 @@ namespace SabreTools.Helper.Tools
.ToArray());
}
+ ///
+ /// Get a proper romba sub path
+ ///
+ /// SHA-1 hash to get the path for
+ /// Subfolder path for the given hash
+ public static string GetRombaPath(string hash)
+ {
+ // If the hash isn't the right size, then we return null
+ if (hash.Length != Constants.SHA1Length)
+ {
+ return null;
+ }
+
+ return Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash.Substring(4, 2), hash.Substring(6, 2), hash + ".gz");
+ }
+
///
/// Get if a string contains Unicode characters
///