mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Convert depot information to keys
This commit is contained in:
@@ -58,8 +58,8 @@ structure according to the original DAT master directory tree structure.";
|
|||||||
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats!, foundDats[key]));
|
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats!, foundDats[key]));
|
||||||
|
|
||||||
// Set the depot values
|
// Set the depot values
|
||||||
datFile.Header.InputDepot = new DepotInformation(true, 4);
|
datFile.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, new DepotInformation(true, 4));
|
||||||
datFile.Header.OutputDepot = new DepotInformation(true, 4);
|
datFile.Header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, new DepotInformation(true, 4));
|
||||||
|
|
||||||
// Create the new output directory if it doesn't exist
|
// Create the new output directory if it doesn't exist
|
||||||
string outputFolder = Path.Combine(outdat, Path.GetFileNameWithoutExtension(foundDats[key]));
|
string outputFolder = Path.Combine(outdat, Path.GetFileNameWithoutExtension(foundDats[key]));
|
||||||
|
|||||||
@@ -456,14 +456,14 @@ namespace SabreTools.DatFiles
|
|||||||
string post = CreatePrefixPostfix(item, false);
|
string post = CreatePrefixPostfix(item, false);
|
||||||
|
|
||||||
// If we're in Depot mode, take care of that instead
|
// If we're in Depot mode, take care of that instead
|
||||||
if (Header.OutputDepot?.IsActive == true)
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive == true)
|
||||||
{
|
{
|
||||||
if (item is Disk disk)
|
if (item is Disk disk)
|
||||||
{
|
{
|
||||||
// We can only write out if there's a SHA-1
|
// We can only write out if there's a SHA-1
|
||||||
if (!string.IsNullOrEmpty(disk.GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key)))
|
if (!string.IsNullOrEmpty(disk.GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key)))
|
||||||
{
|
{
|
||||||
name = Utilities.GetDepotPath(disk.GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key), Header.OutputDepot.Depth)?.Replace('\\', '/');
|
name = Utilities.GetDepotPath(disk.GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key), Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)!.Depth)?.Replace('\\', '/');
|
||||||
item.SetName($"{pre}{name}{post}");
|
item.SetName($"{pre}{name}{post}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -472,7 +472,7 @@ namespace SabreTools.DatFiles
|
|||||||
// We can only write out if there's a SHA-1
|
// We can only write out if there's a SHA-1
|
||||||
if (!string.IsNullOrEmpty(media.GetFieldValue<string?>(Models.Metadata.Media.SHA1Key)))
|
if (!string.IsNullOrEmpty(media.GetFieldValue<string?>(Models.Metadata.Media.SHA1Key)))
|
||||||
{
|
{
|
||||||
name = Utilities.GetDepotPath(media.GetFieldValue<string?>(Models.Metadata.Media.SHA1Key), Header.OutputDepot.Depth)?.Replace('\\', '/');
|
name = Utilities.GetDepotPath(media.GetFieldValue<string?>(Models.Metadata.Media.SHA1Key), Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)!.Depth)?.Replace('\\', '/');
|
||||||
item.SetName($"{pre}{name}{post}");
|
item.SetName($"{pre}{name}{post}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ namespace SabreTools.DatFiles
|
|||||||
// We can only write out if there's a SHA-1
|
// We can only write out if there's a SHA-1
|
||||||
if (!string.IsNullOrEmpty(rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key)))
|
if (!string.IsNullOrEmpty(rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key)))
|
||||||
{
|
{
|
||||||
name = Utilities.GetDepotPath(rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key), Header.OutputDepot.Depth)?.Replace('\\', '/');
|
name = Utilities.GetDepotPath(rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key), Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)!.Depth)?.Replace('\\', '/');
|
||||||
item.SetName($"{pre}{name}{post}");
|
item.SetName($"{pre}{name}{post}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string GameNameKey = "GAMENAME";
|
public const string GameNameKey = "GAMENAME";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Input depot information
|
||||||
|
/// </summary>
|
||||||
|
public const string InputDepotKey = "INPUTDEPOT";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Output depot information
|
||||||
|
/// </summary>
|
||||||
|
public const string OutputDepotKey = "OUTPUTDEPOT";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text to append to all outputted lines
|
/// Text to append to all outputted lines
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -92,22 +102,6 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Depot Information
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Input depot information
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public DepotInformation? InputDepot { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Output depot information
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public DepotInformation? OutputDepot { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal Header model
|
/// Internal Header model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -163,11 +157,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var header = new DatHeader()
|
var header = new DatHeader();
|
||||||
{
|
|
||||||
InputDepot = this.InputDepot?.Clone() as DepotInformation,
|
|
||||||
OutputDepot = this.OutputDepot?.Clone() as DepotInformation,
|
|
||||||
};
|
|
||||||
header.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetFieldValue<string?>(DatHeader.AddExtensionKey));
|
header.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetFieldValue<string?>(DatHeader.AddExtensionKey));
|
||||||
header.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, GetFieldValue<string?>(Models.Metadata.Header.AuthorKey));
|
header.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, GetFieldValue<string?>(Models.Metadata.Header.AuthorKey));
|
||||||
header.SetFieldValue<MergingFlag>(Models.Metadata.Header.BiosModeKey, GetFieldValue<MergingFlag>(Models.Metadata.Header.BiosModeKey));
|
header.SetFieldValue<MergingFlag>(Models.Metadata.Header.BiosModeKey, GetFieldValue<MergingFlag>(Models.Metadata.Header.BiosModeKey));
|
||||||
@@ -190,6 +180,8 @@ namespace SabreTools.DatFiles
|
|||||||
header.SetFieldValue<string?>(Models.Metadata.Header.HomepageKey, GetFieldValue<string?>(Models.Metadata.Header.HomepageKey));
|
header.SetFieldValue<string?>(Models.Metadata.Header.HomepageKey, GetFieldValue<string?>(Models.Metadata.Header.HomepageKey));
|
||||||
header.SetFieldValue<string?>(Models.Metadata.Header.IdKey, GetFieldValue<string?>(Models.Metadata.Header.IdKey));
|
header.SetFieldValue<string?>(Models.Metadata.Header.IdKey, GetFieldValue<string?>(Models.Metadata.Header.IdKey));
|
||||||
header.SetFieldValue<OfflineListInfo[]?>(Models.Metadata.Header.InfosKey, GetFieldValue<OfflineListInfo[]?>(Models.Metadata.Header.InfosKey)); // TODO: Perform a deep clone
|
header.SetFieldValue<OfflineListInfo[]?>(Models.Metadata.Header.InfosKey, GetFieldValue<OfflineListInfo[]?>(Models.Metadata.Header.InfosKey)); // TODO: Perform a deep clone
|
||||||
|
header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
|
||||||
header.SetFieldValue<bool?>(Models.Metadata.Header.LockBiosModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockBiosModeKey));
|
header.SetFieldValue<bool?>(Models.Metadata.Header.LockBiosModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockBiosModeKey));
|
||||||
header.SetFieldValue<bool?>(Models.Metadata.Header.LockRomModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockRomModeKey));
|
header.SetFieldValue<bool?>(Models.Metadata.Header.LockRomModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockRomModeKey));
|
||||||
header.SetFieldValue<bool?>(Models.Metadata.Header.LockSampleModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockSampleModeKey));
|
header.SetFieldValue<bool?>(Models.Metadata.Header.LockSampleModeKey, GetFieldValue<bool?>(Models.Metadata.Header.LockSampleModeKey));
|
||||||
@@ -248,14 +240,12 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DatHeader CloneFiltering()
|
public DatHeader CloneFiltering()
|
||||||
{
|
{
|
||||||
var header = new DatHeader()
|
var header = new DatHeader();
|
||||||
{
|
|
||||||
InputDepot = this.InputDepot?.Clone() as DepotInformation,
|
|
||||||
OutputDepot = this.OutputDepot?.Clone() as DepotInformation,
|
|
||||||
};
|
|
||||||
header.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetFieldValue<string?>(DatHeader.AddExtensionKey));
|
header.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetFieldValue<string?>(DatHeader.AddExtensionKey));
|
||||||
header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
header.SetFieldValue<bool>(DatHeader.GameNameKey, GetFieldValue<bool>(DatHeader.GameNameKey));
|
header.SetFieldValue<bool>(DatHeader.GameNameKey, GetFieldValue<bool>(DatHeader.GameNameKey));
|
||||||
|
header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
|
||||||
header.SetFieldValue<string?>(DatHeader.PostfixKey, GetFieldValue<string?>(DatHeader.PostfixKey));
|
header.SetFieldValue<string?>(DatHeader.PostfixKey, GetFieldValue<string?>(DatHeader.PostfixKey));
|
||||||
header.SetFieldValue<string?>(DatHeader.PrefixKey, GetFieldValue<string?>(DatHeader.PrefixKey));
|
header.SetFieldValue<string?>(DatHeader.PrefixKey, GetFieldValue<string?>(DatHeader.PrefixKey));
|
||||||
header.SetFieldValue<bool>(DatHeader.RemoveExtensionKey, GetFieldValue<bool>(DatHeader.RemoveExtensionKey));
|
header.SetFieldValue<bool>(DatHeader.RemoveExtensionKey, GetFieldValue<bool>(DatHeader.RemoveExtensionKey));
|
||||||
@@ -341,8 +331,8 @@ namespace SabreTools.DatFiles
|
|||||||
if (!string.IsNullOrEmpty(datHeader.GetFieldValue<string?>(DatHeader.ReplaceExtensionKey)))
|
if (!string.IsNullOrEmpty(datHeader.GetFieldValue<string?>(DatHeader.ReplaceExtensionKey)))
|
||||||
SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, datHeader.GetFieldValue<string?>(DatHeader.ReplaceExtensionKey));
|
SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, datHeader.GetFieldValue<string?>(DatHeader.ReplaceExtensionKey));
|
||||||
|
|
||||||
InputDepot = datHeader.InputDepot?.Clone() as DepotInformation;
|
SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, datHeader.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
OutputDepot = datHeader.OutputDepot?.Clone() as DepotInformation;
|
SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, datHeader.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
|
||||||
SetFieldValue<bool>(DatHeader.GameNameKey, datHeader.GetFieldValue<bool>(DatHeader.GameNameKey));
|
SetFieldValue<bool>(DatHeader.GameNameKey, datHeader.GetFieldValue<bool>(DatHeader.GameNameKey));
|
||||||
SetFieldValue<bool>(DatHeader.QuotesKey, datHeader.GetFieldValue<bool>(DatHeader.QuotesKey));
|
SetFieldValue<bool>(DatHeader.QuotesKey, datHeader.GetFieldValue<bool>(DatHeader.QuotesKey));
|
||||||
SetFieldValue<bool>(DatHeader.RemoveExtensionKey, datHeader.GetFieldValue<bool>(DatHeader.RemoveExtensionKey));
|
SetFieldValue<bool>(DatHeader.RemoveExtensionKey, datHeader.GetFieldValue<bool>(DatHeader.RemoveExtensionKey));
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
ProcessItemName(datItem, false, forceRomName: false);
|
ProcessItemName(datItem, false, forceRomName: false);
|
||||||
|
|
||||||
// Romba mode automatically uses item name
|
// Romba mode automatically uses item name
|
||||||
if (Header.OutputDepot?.IsActive == true || Header.GetFieldValue<bool>(DatHeader.UseRomNameKey))
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive == true || Header.GetFieldValue<bool>(DatHeader.UseRomNameKey))
|
||||||
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
||||||
else if (!Header.GetFieldValue<bool>(DatHeader.UseRomNameKey) && datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != lastgame)
|
else if (!Header.GetFieldValue<bool>(DatHeader.UseRomNameKey) && datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != lastgame)
|
||||||
sw.Write($"{datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty}\n");
|
sw.Write($"{datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty}\n");
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace SabreTools.DatTools
|
|||||||
private static bool CheckDepotFile(DatFile datFile, string item)
|
private static bool CheckDepotFile(DatFile datFile, string item)
|
||||||
{
|
{
|
||||||
// If we're not in Depot mode, return false
|
// 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;
|
return false;
|
||||||
|
|
||||||
// Check the file as if it were in a depot
|
// 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)
|
private static void ProcessDirectoryBlanks(DatFile datFile, string? basePath)
|
||||||
{
|
{
|
||||||
// If we're in depot mode, we don't process blanks
|
// 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;
|
return;
|
||||||
|
|
||||||
List<string> empties = basePath.ListEmpty() ?? [];
|
List<string> empties = basePath.ListEmpty() ?? [];
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace SabreTools.DatTools
|
|||||||
logger.User($"Checking hash '{hash}'");
|
logger.User($"Checking hash '{hash}'");
|
||||||
|
|
||||||
// Get the extension path for the 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)
|
if (subpath == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ namespace SabreTools.DatTools
|
|||||||
// Get the proper output path
|
// Get the proper output path
|
||||||
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
|
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
|
||||||
if (outputFormat == OutputFormat.TorrentGzipRomba)
|
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
|
else
|
||||||
outDir = Path.Combine(outDir, sha1 + ".gz");
|
outDir = Path.Combine(outDir, sha1 + ".gz");
|
||||||
|
|
||||||
@@ -636,7 +636,7 @@ namespace SabreTools.DatTools
|
|||||||
// Get the proper output path
|
// Get the proper output path
|
||||||
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
|
string sha1 = (datItem as Rom)!.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key) ?? string.Empty;
|
||||||
if (outputFormat == OutputFormat.TorrentXZRomba)
|
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
|
else
|
||||||
outDir = Path.Combine(outDir, sha1 + ".xz");
|
outDir = Path.Combine(outDir, sha1 + ".xz");
|
||||||
|
|
||||||
@@ -728,9 +728,9 @@ namespace SabreTools.DatTools
|
|||||||
|
|
||||||
// Set the depth fields where appropriate
|
// Set the depth fields where appropriate
|
||||||
if (outputArchive is GZipArchive gzipArchive)
|
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)
|
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;
|
return outputArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace SabreTools.DatTools
|
|||||||
logger.User($"Checking hash '{hash}'");
|
logger.User($"Checking hash '{hash}'");
|
||||||
|
|
||||||
// Get the extension path for the 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)
|
if (subpath == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -2148,18 +2148,17 @@ Some special strings that can be used:
|
|||||||
/// Get DatHeader from feature list
|
/// Get DatHeader from feature list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DatHeader? GetDatHeader(Dictionary<string, Feature?> features)
|
private DatHeader? GetDatHeader(Dictionary<string, Feature?> features)
|
||||||
{
|
|
||||||
// TODO: Sort this by region, like the actual header
|
|
||||||
var datHeader = new DatHeader()
|
|
||||||
{
|
{
|
||||||
// Get the depot information
|
// Get the depot information
|
||||||
InputDepot = new DepotInformation(
|
var inputDepot = new DepotInformation(
|
||||||
GetBoolean(features, DepotValue),
|
GetBoolean(features, DepotValue),
|
||||||
GetInt32(features, DepotDepthInt32Value)),
|
GetInt32(features, DepotDepthInt32Value));
|
||||||
OutputDepot = new DepotInformation(
|
var outputDepot = new DepotInformation(
|
||||||
GetBoolean(features, RombaValue),
|
GetBoolean(features, RombaValue),
|
||||||
GetInt32(features, RombaDepthInt32Value))
|
GetInt32(features, RombaDepthInt32Value));
|
||||||
};
|
|
||||||
|
var datHeader = new DatHeader();
|
||||||
|
datHeader.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetString(features, AddExtensionStringValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, GetString(features, AuthorStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, GetString(features, AuthorStringValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CategoryKey, GetString(features, CategoryStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CategoryKey, GetString(features, CategoryStringValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CommentKey, GetString(features, CommentStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CommentKey, GetString(features, CommentStringValue));
|
||||||
@@ -2170,22 +2169,22 @@ Some special strings that can be used:
|
|||||||
datHeader.SetFieldValue<MergingFlag>(Models.Metadata.Header.ForceMergingKey, GetString(features, ForceMergingStringValue).AsEnumValue<MergingFlag>());
|
datHeader.SetFieldValue<MergingFlag>(Models.Metadata.Header.ForceMergingKey, GetString(features, ForceMergingStringValue).AsEnumValue<MergingFlag>());
|
||||||
datHeader.SetFieldValue<NodumpFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForceNodumpStringValue).AsEnumValue<NodumpFlag>());
|
datHeader.SetFieldValue<NodumpFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForceNodumpStringValue).AsEnumValue<NodumpFlag>());
|
||||||
datHeader.SetFieldValue<PackingFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForcePackingStringValue).AsEnumValue<PackingFlag>());
|
datHeader.SetFieldValue<PackingFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForcePackingStringValue).AsEnumValue<PackingFlag>());
|
||||||
|
datHeader.SetFieldValue<bool>(DatHeader.GameNameKey, GetBoolean(features, GamePrefixValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, GetString(features, HeaderStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, GetString(features, HeaderStringValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HomepageKey, GetString(features, HomepageStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HomepageKey, GetString(features, HomepageStringValue));
|
||||||
|
datHeader.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, inputDepot);
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.NameKey, GetString(features, NameStringValue));
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.NameKey, GetString(features, NameStringValue));
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.RootDirKey, GetString(features, RootStringValue));
|
datHeader.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, outputDepot);
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.TypeKey, GetBoolean(features, SuperdatValue) ? "SuperDAT" : null);
|
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.UrlKey, GetString(features, UrlStringValue));
|
|
||||||
datHeader.SetFieldValue<string?>(Models.Metadata.Header.VersionKey, GetString(features, VersionStringValue));
|
|
||||||
|
|
||||||
datHeader.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetString(features, AddExtensionStringValue));
|
|
||||||
datHeader.SetFieldValue<bool>(DatHeader.GameNameKey, GetBoolean(features, GamePrefixValue));
|
|
||||||
datHeader.SetFieldValue<string?>(DatHeader.PostfixKey, GetString(features, PostfixStringValue));
|
datHeader.SetFieldValue<string?>(DatHeader.PostfixKey, GetString(features, PostfixStringValue));
|
||||||
datHeader.SetFieldValue<string?>(DatHeader.PrefixKey, GetString(features, PrefixStringValue));
|
datHeader.SetFieldValue<string?>(DatHeader.PrefixKey, GetString(features, PrefixStringValue));
|
||||||
datHeader.SetFieldValue<bool>(DatHeader.QuotesKey, GetBoolean(features, QuotesValue));
|
datHeader.SetFieldValue<bool>(DatHeader.QuotesKey, GetBoolean(features, QuotesValue));
|
||||||
datHeader.SetFieldValue<bool>(DatHeader.RemoveExtensionKey, GetBoolean(features, RemoveExtensionsValue));
|
datHeader.SetFieldValue<bool>(DatHeader.RemoveExtensionKey, GetBoolean(features, RemoveExtensionsValue));
|
||||||
datHeader.SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, GetString(features, ReplaceExtensionStringValue));
|
datHeader.SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, GetString(features, ReplaceExtensionStringValue));
|
||||||
datHeader.SetFieldValue<bool>(DatHeader.UseRomNameKey, GetBoolean(features, RomsValue));
|
datHeader.SetFieldValue<bool>(DatHeader.UseRomNameKey, GetBoolean(features, RomsValue));
|
||||||
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.RootDirKey, GetString(features, RootStringValue));
|
||||||
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.TypeKey, GetBoolean(features, SuperdatValue) ? "SuperDAT" : null);
|
||||||
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.UrlKey, GetString(features, UrlStringValue));
|
||||||
|
datHeader.SetFieldValue<string?>(Models.Metadata.Header.VersionKey, GetString(features, VersionStringValue));
|
||||||
|
|
||||||
bool deprecated = GetBoolean(features, DeprecatedValue);
|
bool deprecated = GetBoolean(features, DeprecatedValue);
|
||||||
foreach (string ot in GetList(features, OutputTypeListValue))
|
foreach (string ot in GetList(features, OutputTypeListValue))
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace SabreTools.Features
|
|||||||
var outputFormat = GetOutputFormat(features);
|
var outputFormat = GetOutputFormat(features);
|
||||||
|
|
||||||
// If we have the romba flag
|
// If we have the romba flag
|
||||||
if (Header!.OutputDepot?.IsActive == true)
|
if (Header!.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive == true)
|
||||||
{
|
{
|
||||||
// Update TorrentGzip output
|
// Update TorrentGzip output
|
||||||
if (outputFormat == OutputFormat.TorrentGzip)
|
if (outputFormat == OutputFormat.TorrentGzip)
|
||||||
@@ -98,8 +98,8 @@ namespace SabreTools.Features
|
|||||||
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
datdata.Header.InputDepot = Header.InputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
datdata.Header.OutputDepot = Header.OutputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
|
||||||
// If we have overridden the header skipper, set it now
|
// If we have overridden the header skipper, set it now
|
||||||
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
||||||
@@ -107,7 +107,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// If we have the depot flag, respect it
|
// If we have the depot flag, respect it
|
||||||
bool success;
|
bool success;
|
||||||
if (Header.InputDepot?.IsActive ?? false)
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
|
||||||
success = Rebuilder.RebuildDepot(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), date, delete, inverse, outputFormat);
|
success = Rebuilder.RebuildDepot(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), date, delete, inverse, outputFormat);
|
||||||
else
|
else
|
||||||
success = Rebuilder.RebuildGeneric(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), quickScan, date, delete, inverse, outputFormat, asFiles);
|
success = Rebuilder.RebuildGeneric(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), quickScan, date, delete, inverse, outputFormat, asFiles);
|
||||||
@@ -137,8 +137,8 @@ namespace SabreTools.Features
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
datdata.Header.InputDepot = Header.InputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
datdata.Header.OutputDepot = Header.OutputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
|
||||||
// If we have overridden the header skipper, set it now
|
// If we have overridden the header skipper, set it now
|
||||||
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
||||||
@@ -148,7 +148,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// If we have the depot flag, respect it
|
// If we have the depot flag, respect it
|
||||||
bool success;
|
bool success;
|
||||||
if (Header.InputDepot?.IsActive ?? false)
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
|
||||||
success = Rebuilder.RebuildDepot(datdata, Inputs, OutputDir!, date, delete, inverse, outputFormat);
|
success = Rebuilder.RebuildDepot(datdata, Inputs, OutputDir!, date, delete, inverse, outputFormat);
|
||||||
else
|
else
|
||||||
success = Rebuilder.RebuildGeneric(datdata, Inputs, OutputDir!, quickScan, date, delete, inverse, outputFormat, asFiles);
|
success = Rebuilder.RebuildGeneric(datdata, Inputs, OutputDir!, quickScan, date, delete, inverse, outputFormat, asFiles);
|
||||||
|
|||||||
@@ -72,14 +72,14 @@ namespace SabreTools.Features
|
|||||||
Remover!.ApplyRemovals(datdata);
|
Remover!.ApplyRemovals(datdata);
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
datdata.Header.InputDepot = Header!.InputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header!.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
|
||||||
// If we have overridden the header skipper, set it now
|
// If we have overridden the header skipper, set it now
|
||||||
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
||||||
datdata.Header.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey));
|
datdata.Header.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey));
|
||||||
|
|
||||||
// If we have the depot flag, respect it
|
// If we have the depot flag, respect it
|
||||||
if (Header.InputDepot?.IsActive ?? false)
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
|
||||||
{
|
{
|
||||||
Verification.VerifyDepot(datdata, Inputs);
|
Verification.VerifyDepot(datdata, Inputs);
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ namespace SabreTools.Features
|
|||||||
Remover!.ApplyRemovals(datdata);
|
Remover!.ApplyRemovals(datdata);
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
datdata.Header.InputDepot = Header!.InputDepot?.Clone() as DepotInformation;
|
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header!.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
|
||||||
|
|
||||||
// If we have overridden the header skipper, set it now
|
// If we have overridden the header skipper, set it now
|
||||||
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
|
||||||
@@ -129,7 +129,7 @@ namespace SabreTools.Features
|
|||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
// If we have the depot flag, respect it
|
// If we have the depot flag, respect it
|
||||||
if (Header.InputDepot?.IsActive ?? false)
|
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
|
||||||
{
|
{
|
||||||
Verification.VerifyDepot(datdata, Inputs);
|
Verification.VerifyDepot(datdata, Inputs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user