Replace RVX with Depth

This commit is contained in:
Matt Nadareski
2020-08-18 23:39:13 -07:00
parent a703e22234
commit 52c15d4732
23 changed files with 473 additions and 546 deletions

View File

@@ -37,21 +37,30 @@ namespace SabreTools.Library.IO
/// Get a proper romba sub path
/// </summary>
/// <param name="hash">SHA-1 hash to get the path for</param>
/// <param name="rvx">True to only go to 2-deep, false to default to 4-deep</param>
/// <param name="depth">Positive value representing the depth of the depot</param>
/// <returns>Subfolder path for the given hash</returns>
public static string GetRombaPath(string hash, bool rvx)
public static string GetRombaPath(string hash, int depth)
{
// If the hash isn't the right size, then we return null
if (hash.Length != Constants.SHA1Length) // TODO: When updating to SHA-256, this needs to update to Constants.SHA256Length
return null;
// RVX uses a 2-deep RomRoot
if (rvx)
return Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash + ".gz");
// Cap the depth between 0 and 20, for now
if (depth < 0)
depth = 0;
else if (depth > Constants.SHA1ZeroBytes.Length)
depth = Constants.SHA1ZeroBytes.Length;
// Romba uses a 4-deep Depot
else
return Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash.Substring(4, 2), hash.Substring(6, 2), hash + ".gz");
// Loop through and generate the subdirectory
string path = string.Empty;
for (int i = 0; i < depth; i++)
{
path += hash.Substring(i * 2, 2) + Path.DirectorySeparatorChar;
}
// Now append the filename
path += hash + $"{hash}.gz";
return path;
}
/// <summary>