Convert depot information to keys

This commit is contained in:
Matt Nadareski
2024-03-10 22:08:08 -04:00
parent 1d1cbc3357
commit 962fd8baee
10 changed files with 59 additions and 70 deletions

View File

@@ -210,7 +210,7 @@ namespace SabreTools.DatTools
private static bool CheckDepotFile(DatFile datFile, string item)
{
// If we're not in Depot mode, return false
if (datFile.Header.OutputDepot?.IsActive != true)
if (datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive != true)
return false;
// Check the file as if it were in a depot
@@ -321,7 +321,7 @@ namespace SabreTools.DatTools
private static void ProcessDirectoryBlanks(DatFile datFile, string? basePath)
{
// If we're in depot mode, we don't process blanks
if (datFile.Header.OutputDepot?.IsActive == true)
if (datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive == true)
return;
List<string> empties = basePath.ListEmpty() ?? [];

View File

@@ -120,7 +120,7 @@ namespace SabreTools.DatTools
logger.User($"Checking hash '{hash}'");
// Get the extension path for the hash
string? subpath = Utilities.GetDepotPath(hash, datFile.Header.InputDepot?.Depth ?? 0);
string? subpath = Utilities.GetDepotPath(hash, datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Depth ?? 0);
if (subpath == null)
continue;
@@ -590,7 +590,7 @@ namespace SabreTools.DatTools
// Get the proper output path
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
if (outputFormat == OutputFormat.TorrentGzipRomba)
outDir = Path.Combine(outDir, Utilities.GetDepotPath(sha1, datFile.Header.OutputDepot?.Depth ?? 0) ?? string.Empty);
outDir = Path.Combine(outDir, Utilities.GetDepotPath(sha1, datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Depth ?? 0) ?? string.Empty);
else
outDir = Path.Combine(outDir, sha1 + ".gz");
@@ -636,7 +636,7 @@ namespace SabreTools.DatTools
// Get the proper output path
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
if (outputFormat == OutputFormat.TorrentXZRomba)
outDir = Path.Combine(outDir, Utilities.GetDepotPath(sha1, datFile.Header.OutputDepot?.Depth ?? 0) ?? string.Empty).Replace(".gz", ".xz");
outDir = Path.Combine(outDir, Utilities.GetDepotPath(sha1, datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Depth ?? 0) ?? string.Empty).Replace(".gz", ".xz");
else
outDir = Path.Combine(outDir, sha1 + ".xz");
@@ -728,9 +728,9 @@ namespace SabreTools.DatTools
// Set the depth fields where appropriate
if (outputArchive is GZipArchive gzipArchive)
gzipArchive.Depth = datFile.Header.OutputDepot?.Depth ?? 0;
gzipArchive.Depth = datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Depth ?? 0;
else if (outputArchive is XZArchive xzArchive)
xzArchive.Depth = datFile.Header.OutputDepot?.Depth ?? 0;
xzArchive.Depth = datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Depth ?? 0;
return outputArchive;
}

View File

@@ -69,7 +69,7 @@ namespace SabreTools.DatTools
logger.User($"Checking hash '{hash}'");
// Get the extension path for the hash
string? subpath = Utilities.GetDepotPath(hash, datFile.Header.InputDepot?.Depth ?? 0);
string? subpath = Utilities.GetDepotPath(hash, datFile.Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Depth ?? 0);
if (subpath == null)
continue;