From 3e320bb85ed6aa406147070b113dda65fadb5f90 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 20 Aug 2020 11:23:48 -0700 Subject: [PATCH] Add and use DepotInformation --- RombaSharp/Features/Build.cs | 6 +- SabreTools.Library/DatFiles/DatFile.cs | 55 +++++------- SabreTools.Library/DatFiles/DatHeader.cs | 84 +++++++++---------- .../DatFiles/DepotInformation.cs | 60 +++++++++++++ SabreTools.Library/DatFiles/Missfile.cs | 2 +- SabreTools.Library/FileTypes/GZipArchive.cs | 2 +- SabreTools.Library/FileTypes/XZArchive.cs | 2 +- SabreTools.Library/IO/PathExtensions.cs | 2 +- SabreTools/Features/BaseFeature.cs | 12 +-- SabreTools/Features/Sort.cs | 34 ++++---- SabreTools/Features/Verify.cs | 20 ++--- 11 files changed, 165 insertions(+), 114 deletions(-) create mode 100644 SabreTools.Library/DatFiles/DepotInformation.cs diff --git a/RombaSharp/Features/Build.cs b/RombaSharp/Features/Build.cs index 832df2f6..0076458c 100644 --- a/RombaSharp/Features/Build.cs +++ b/RombaSharp/Features/Build.cs @@ -52,6 +52,10 @@ structure according to the original DAT master directory tree structure."; // Get the DAT file associated with the key DatFile datFile = DatFile.CreateAndParse(Path.Combine(_dats, foundDats[key])); + // Set the depot values + datFile.Header.InputDepot = new DepotInformation(true, 4); + datFile.Header.OutputDepot = new DepotInformation(true, 4); + // Create the new output directory if it doesn't exist string outputFolder = Path.Combine(outdat, Path.GetFileNameWithoutExtension(foundDats[key])); DirectoryExtensions.Ensure(outputFolder, create: true); @@ -62,8 +66,6 @@ structure according to the original DAT master directory tree structure."; // Now scan all of those depots and rebuild datFile.RebuildDepot( onlineDepots, - indepth: 4, - outdepth: 4, outDir: outputFolder, outputFormat: (copy ? OutputFormat.TorrentGzipRomba : OutputFormat.TorrentZip), updateDat: false); diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index f4d4e4ad..87eab4ff 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -2045,7 +2045,7 @@ namespace SabreTools.Library.DatFiles }); // Now find all folders that are empty, if we are supposed to - if (!Header.Romba && addBlanks) + if (!Header.OutputDepot.IsActive && addBlanks) { List empties = DirectoryExtensions.ListEmpty(basePath); Parallel.ForEach(empties, Globals.ParallelOptions, dir => @@ -2119,8 +2119,8 @@ namespace SabreTools.Library.DatFiles bool addDate, bool copyFiles) { - // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes) - if (Header.Romba) + // Special case for if we are in Depot mode (all names are supposed to be SHA-1 hashes) + if (Header.OutputDepot.IsActive) { GZipArchive gzarc = new GZipArchive(item); BaseFile baseFile = gzarc.GetTorrentGZFileInfo(); @@ -2342,8 +2342,6 @@ namespace SabreTools.Library.DatFiles /// Process the DAT and find all matches in input files and folders assuming they're a depot /// /// List of input files/folders to check - /// Positive value representing depth of input depot - /// Positive value representing depth of output depot /// Output directory to use to build to /// True if the date from the DAT should be used if available, false otherwise /// True if input files should be deleted, false otherwise @@ -2353,8 +2351,6 @@ namespace SabreTools.Library.DatFiles /// True if rebuilding was a success, false otherwise public bool RebuildDepot( List inputs, - int indepth = 4, - int outdepth = 4, string outDir = null, bool date = false, bool delete = false, @@ -2463,7 +2459,7 @@ namespace SabreTools.Library.DatFiles Globals.Logger.User($"Checking hash '{hash}'"); // Get the extension path for the hash - string subpath = PathExtensions.GetRombaPath(hash, indepth); + string subpath = PathExtensions.GetDepotPath(hash, Header.InputDepot.Depth); // Find the first depot that includes the hash string foundpath = null; @@ -2495,9 +2491,9 @@ namespace SabreTools.Library.DatFiles // Otherwise, we rebuild that file to all locations that we need to bool usedInternally; if (Items[hash][0].ItemType == ItemType.Disk) - usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, outdepth, date, inverse, outputFormat, updateDat, false /* isZip */); + usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */); else - usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, outdepth, date, inverse, outputFormat, updateDat, false /* isZip */); + usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */); // If we are supposed to delete the depot file, do so if (delete && usedInternally) @@ -2526,7 +2522,6 @@ namespace SabreTools.Library.DatFiles /// /// List of input files/folders to check /// Output directory to use to build to - /// Positive value representing depth of output depot /// True to enable external scanning of archives, false otherwise /// True if the date from the DAT should be used if available, false otherwise /// True if input files should be deleted, false otherwise @@ -2538,7 +2533,6 @@ namespace SabreTools.Library.DatFiles public bool RebuildGeneric( List inputs, string outDir = null, - int outdepth = 4, bool quickScan = false, bool date = false, bool delete = false, @@ -2626,7 +2620,7 @@ namespace SabreTools.Library.DatFiles if (File.Exists(input)) { Globals.Logger.User($"Checking file: {input}"); - RebuildGenericHelper(input, outDir, outdepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); + RebuildGenericHelper(input, outDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); } // If the input is a directory @@ -2636,7 +2630,7 @@ namespace SabreTools.Library.DatFiles foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories)) { Globals.Logger.User($"Checking file: {file}"); - RebuildGenericHelper(file, outDir, outdepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); + RebuildGenericHelper(file, outDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); } } } @@ -2663,7 +2657,6 @@ namespace SabreTools.Library.DatFiles /// /// Name of the file to process /// Output directory to use to build to - /// Positive value representing depth of output depot /// True to enable external scanning of archives, false otherwise /// True if the date from the DAT should be used if available, false otherwise /// True if input files should be deleted, false otherwise @@ -2674,7 +2667,6 @@ namespace SabreTools.Library.DatFiles private void RebuildGenericHelper( string file, string outDir, - int outdepth, bool quickScan, bool date, bool delete, @@ -2702,7 +2694,7 @@ namespace SabreTools.Library.DatFiles else if (externalFileInfo.Type == FileType.None) externalDatItem = new Rom(externalFileInfo); - usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, null /* isZip */); + usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, date, inverse, outputFormat, updateDat, null /* isZip */); // Scan the file internally @@ -2735,7 +2727,7 @@ namespace SabreTools.Library.DatFiles else if (internalFileInfo.Type == FileType.None) internalDatItem = new Rom(internalFileInfo); - usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, null /* isZip */); + usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, null /* isZip */); } // Otherwise, loop through the entries and try to match else @@ -2743,7 +2735,7 @@ namespace SabreTools.Library.DatFiles foreach (BaseFile entry in entries) { DatItem internalDatItem = DatItem.Create(entry); - usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */); + usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */); } } @@ -2758,7 +2750,6 @@ namespace SabreTools.Library.DatFiles /// Information for the current file to rebuild from /// Name of the file to process /// Output directory to use to build to - /// Positive value representing depth of output depot /// True if the date from the DAT should be used if available, false otherwise /// True if the DAT should be used as a filter instead of a template, false otherwise /// Output format that files should be written to @@ -2769,7 +2760,6 @@ namespace SabreTools.Library.DatFiles DatItem datItem, string file, string outDir, - int outdepth, bool date, bool inverse, OutputFormat outputFormat, @@ -2811,7 +2801,7 @@ namespace SabreTools.Library.DatFiles // Get the proper output path if (outputFormat == OutputFormat.TorrentGzipRomba) - outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, outdepth)); + outDir = Path.Combine(outDir, PathExtensions.GetDepotPath(sha1, Header.OutputDepot.Depth)); else outDir = Path.Combine(outDir, sha1 + ".gz"); @@ -2839,7 +2829,7 @@ namespace SabreTools.Library.DatFiles // Get the proper output path if (outputFormat == OutputFormat.TorrentXZRomba) - outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, outdepth)); + outDir = Path.Combine(outDir, PathExtensions.GetDepotPath(sha1, Header.OutputDepot.Depth)); else outDir = Path.Combine(outDir, sha1 + ".xz"); @@ -2912,7 +2902,7 @@ namespace SabreTools.Library.DatFiles Folder outputArchive = Folder.Create(outputFormat); // Now rebuild to the output file - outputArchive.Write(fileStream, outDir, (Rom)item, date: date, depth: outdepth); + outputArchive.Write(fileStream, outDir, (Rom)item, date: date, depth: Header.OutputDepot.Depth); } // Close the input stream @@ -2979,8 +2969,8 @@ namespace SabreTools.Library.DatFiles Folder outputArchive = Folder.Create(outputFormat); // Now rebuild to the output file - eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, depth: outdepth); - eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, depth: outdepth); + eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, depth: Header.OutputDepot.Depth); + eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, depth: Header.OutputDepot.Depth); // Now add the success of either rebuild rebuilt &= eitherSuccess; @@ -3003,10 +2993,9 @@ namespace SabreTools.Library.DatFiles /// Process the DAT and verify from the depots /// /// List of input directories to compare against - /// Positive value representing depot depth, defaults to 4 /// Optional param for output directory /// True if verification was a success, false otherwise - public bool VerifyDepot(List inputs, int depth = 4, string outDir = null) + public bool VerifyDepot(List inputs, string outDir = null) { bool success = true; @@ -3042,7 +3031,7 @@ namespace SabreTools.Library.DatFiles Globals.Logger.User($"Checking hash '{hash}'"); // Get the extension path for the hash - string subpath = PathExtensions.GetRombaPath(hash, depth); + string subpath = PathExtensions.GetDepotPath(hash, Header.InputDepot.Depth); // Find the first depot that includes the hash string foundpath = null; @@ -3723,8 +3712,8 @@ namespace SabreTools.Library.DatFiles string pre = CreatePrefixPostfix(item, true); string post = CreatePrefixPostfix(item, false); - // If we're in Romba mode, take care of that instead - if (Header.Romba) + // If we're in Depot mode, take care of that instead + if (Header.OutputDepot.IsActive) { if (item.ItemType == ItemType.Rom) { @@ -3733,7 +3722,7 @@ namespace SabreTools.Library.DatFiles // We can only write out if there's a SHA-1 if (!string.IsNullOrWhiteSpace(romItem.SHA1)) { - name = PathExtensions.GetRombaPath(romItem.SHA1, Header.RombaDepth).Replace('\\', '/'); + name = PathExtensions.GetDepotPath(romItem.SHA1, Header.OutputDepot.Depth).Replace('\\', '/'); item.Name = $"{pre}{name}{post}"; } } @@ -3744,7 +3733,7 @@ namespace SabreTools.Library.DatFiles // We can only write out if there's a SHA-1 if (!string.IsNullOrWhiteSpace(diskItem.SHA1)) { - name = PathExtensions.GetRombaPath(diskItem.SHA1, Header.RombaDepth).Replace('\\', '/'); + name = PathExtensions.GetDepotPath(diskItem.SHA1, Header.OutputDepot.Depth).Replace('\\', '/'); item.Name = pre + name + post; } } diff --git a/SabreTools.Library/DatFiles/DatHeader.cs b/SabreTools.Library/DatFiles/DatHeader.cs index fb4a73d8..461207cf 100644 --- a/SabreTools.Library/DatFiles/DatHeader.cs +++ b/SabreTools.Library/DatFiles/DatHeader.cs @@ -211,16 +211,16 @@ namespace SabreTools.Library.DatFiles public bool RemoveExtension { get; set; } /// - /// Romba output mode + /// Input depot information /// [JsonIgnore] - public bool Romba { get; set; } + public DepotInformation InputDepot { get; set; } /// - /// Romba depth + /// Output depot information /// [JsonIgnore] - public int RombaDepth { get; set; } = 4; + public DepotInformation OutputDepot { get; set; } /// /// Output the machine name @@ -294,8 +294,8 @@ namespace SabreTools.Library.DatFiles AddExtension = this.AddExtension, RemoveExtension = this.RemoveExtension, GameName = this.GameName, - Romba = this.Romba, - RombaDepth = this.RombaDepth, + InputDepot = this.InputDepot.Clone() as DepotInformation, + OutputDepot = this.OutputDepot.Clone() as DepotInformation, }; } @@ -358,8 +358,8 @@ namespace SabreTools.Library.DatFiles AddExtension = this.AddExtension, RemoveExtension = this.RemoveExtension, GameName = this.GameName, - Romba = this.Romba, - RombaDepth = this.RombaDepth, + InputDepot = this.InputDepot.Clone() as DepotInformation, + OutputDepot = this.OutputDepot.Clone() as DepotInformation, }; } @@ -370,86 +370,86 @@ namespace SabreTools.Library.DatFiles public void ConditionalCopy(DatHeader datHeader) { if (!string.IsNullOrWhiteSpace(datHeader.FileName)) - this.FileName = datHeader.FileName; + FileName = datHeader.FileName; if (!string.IsNullOrWhiteSpace(datHeader.Name)) - this.Name = datHeader.Name; + Name = datHeader.Name; if (!string.IsNullOrWhiteSpace(datHeader.Description)) - this.Description = datHeader.Description; + Description = datHeader.Description; if (!string.IsNullOrWhiteSpace(datHeader.RootDir)) - this.RootDir = datHeader.RootDir; + RootDir = datHeader.RootDir; if (!string.IsNullOrWhiteSpace(datHeader.Category)) - this.Category = datHeader.Category; + Category = datHeader.Category; if (!string.IsNullOrWhiteSpace(datHeader.Version)) - this.Version = datHeader.Version; + Version = datHeader.Version; if (!string.IsNullOrWhiteSpace(datHeader.Date)) - this.Date = datHeader.Date; + Date = datHeader.Date; if (!string.IsNullOrWhiteSpace(datHeader.Author)) - this.Author = datHeader.Author; + Author = datHeader.Author; if (!string.IsNullOrWhiteSpace(datHeader.Email)) - this.Email = datHeader.Email; + Email = datHeader.Email; if (!string.IsNullOrWhiteSpace(datHeader.Homepage)) - this.Homepage = datHeader.Homepage; + Homepage = datHeader.Homepage; if (!string.IsNullOrWhiteSpace(datHeader.Url)) - this.Url = datHeader.Url; + Url = datHeader.Url; if (!string.IsNullOrWhiteSpace(datHeader.Comment)) - this.Comment = datHeader.Comment; + Comment = datHeader.Comment; if (!string.IsNullOrWhiteSpace(datHeader.HeaderSkipper)) - this.HeaderSkipper = datHeader.HeaderSkipper; + HeaderSkipper = datHeader.HeaderSkipper; if (!string.IsNullOrWhiteSpace(datHeader.Type)) - this.Type = datHeader.Type; + Type = datHeader.Type; if (datHeader.ForceMerging != ForceMerging.None) - this.ForceMerging = datHeader.ForceMerging; + ForceMerging = datHeader.ForceMerging; if (datHeader.ForceNodump != ForceNodump.None) - this.ForceNodump = datHeader.ForceNodump; + ForceNodump = datHeader.ForceNodump; if (datHeader.ForcePacking != ForcePacking.None) - this.ForcePacking = datHeader.ForcePacking; + ForcePacking = datHeader.ForcePacking; if (datHeader.DatFormat != 0x00) - this.DatFormat = datHeader.DatFormat; + DatFormat = datHeader.DatFormat; if (datHeader.ExcludeFields != null) - this.ExcludeFields = datHeader.ExcludeFields; + ExcludeFields = datHeader.ExcludeFields; - this.OneRomPerGame = datHeader.OneRomPerGame; - this.KeepEmptyGames = datHeader.KeepEmptyGames; - this.SceneDateStrip = datHeader.SceneDateStrip; - this.DedupeRoms = datHeader.DedupeRoms; - //this.StripHash = datHeader.StripHash; + OneRomPerGame = datHeader.OneRomPerGame; + KeepEmptyGames = datHeader.KeepEmptyGames; + SceneDateStrip = datHeader.SceneDateStrip; + DedupeRoms = datHeader.DedupeRoms; + //StripHash = datHeader.StripHash; if (!string.IsNullOrWhiteSpace(datHeader.Prefix)) - this.Prefix = datHeader.Prefix; + Prefix = datHeader.Prefix; if (!string.IsNullOrWhiteSpace(datHeader.Postfix)) - this.Postfix = datHeader.Postfix; + Postfix = datHeader.Postfix; if (!string.IsNullOrWhiteSpace(datHeader.AddExtension)) - this.AddExtension = datHeader.AddExtension; + AddExtension = datHeader.AddExtension; if (!string.IsNullOrWhiteSpace(datHeader.ReplaceExtension)) - this.ReplaceExtension = datHeader.ReplaceExtension; + ReplaceExtension = datHeader.ReplaceExtension; - this.RemoveExtension = datHeader.RemoveExtension; - this.Romba = datHeader.Romba; - this.RombaDepth = datHeader.RombaDepth; - this.GameName = datHeader.GameName; - this.Quotes = datHeader.Quotes; - this.UseRomName = datHeader.UseRomName; + RemoveExtension = datHeader.RemoveExtension; + InputDepot = datHeader.InputDepot.Clone() as DepotInformation; + OutputDepot = datHeader.OutputDepot.Clone() as DepotInformation; + GameName = datHeader.GameName; + Quotes = datHeader.Quotes; + UseRomName = datHeader.UseRomName; } #endregion diff --git a/SabreTools.Library/DatFiles/DepotInformation.cs b/SabreTools.Library/DatFiles/DepotInformation.cs new file mode 100644 index 00000000..63051894 --- /dev/null +++ b/SabreTools.Library/DatFiles/DepotInformation.cs @@ -0,0 +1,60 @@ +using System; + +using SabreTools.Library.Data; + +namespace SabreTools.Library.DatFiles +{ + public class DepotInformation : ICloneable + { + /// + /// Name or path of the Depot + /// + public string Name { get; private set; } + + /// + /// Whether to use this Depot or not + /// + public bool IsActive { get; private set; } + + /// + /// Depot byte-depth + /// + public int Depth { get; private set; } + + /// + /// Constructor + /// + /// Set active state + /// Set depth between 0 and SHA-1's byte length + public DepotInformation(bool isActive = false, int depth = 4) + { + IsActive = isActive; + Depth = depth; + + // Limit depth value + if (Depth == Int32.MinValue) + Depth = 4; + else if (Depth < 0) + Depth = 0; + else if (Depth > Constants.SHA1Zero.Length) + Depth = Constants.SHA1Zero.Length; + } + + #region Cloning + + /// + /// Clone the current object + /// + public object Clone() + { + return new DepotInformation + { + Name = this.Name, + IsActive = this.IsActive, + Depth = this.Depth, + }; + } + + #endregion + } +} diff --git a/SabreTools.Library/DatFiles/Missfile.cs b/SabreTools.Library/DatFiles/Missfile.cs index 18d576c5..d1970668 100644 --- a/SabreTools.Library/DatFiles/Missfile.cs +++ b/SabreTools.Library/DatFiles/Missfile.cs @@ -136,7 +136,7 @@ namespace SabreTools.Library.DatFiles ProcessItemName(datItem, false, forceRomName: false); // Romba mode automatically uses item name - if (Header.Romba || Header.UseRomName) + if (Header.OutputDepot.IsActive || Header.UseRomName) { sw.Write($"{datItem.GetField(Field.Name, Header.ExcludeFields)}\n"); } diff --git a/SabreTools.Library/FileTypes/GZipArchive.cs b/SabreTools.Library/FileTypes/GZipArchive.cs index 0f3995d8..20311972 100644 --- a/SabreTools.Library/FileTypes/GZipArchive.cs +++ b/SabreTools.Library/FileTypes/GZipArchive.cs @@ -457,7 +457,7 @@ namespace SabreTools.Library.FileTypes rom = new Rom(inputStream.GetInfo(keepReadOpen: true)); // Get the output file name - string outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, depth)); // TODO: When updating to SHA-256, this needs to update to SHA256 + string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, depth)); // TODO: When updating to SHA-256, this needs to update to SHA256 // Check to see if the folder needs to be created if (!Directory.Exists(Path.GetDirectoryName(outfile))) diff --git a/SabreTools.Library/FileTypes/XZArchive.cs b/SabreTools.Library/FileTypes/XZArchive.cs index ee33efba..a44a3aef 100644 --- a/SabreTools.Library/FileTypes/XZArchive.cs +++ b/SabreTools.Library/FileTypes/XZArchive.cs @@ -357,7 +357,7 @@ namespace SabreTools.Library.FileTypes rom = new Rom(inputStream.GetInfo(keepReadOpen: true)); // Get the output file name - string outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, depth)); // TODO: When updating to SHA-256, this needs to update to SHA256 + string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, depth)); // TODO: When updating to SHA-256, this needs to update to SHA256 outfile = outfile.Replace(".gz", ".xz"); // Check to see if the folder needs to be created diff --git a/SabreTools.Library/IO/PathExtensions.cs b/SabreTools.Library/IO/PathExtensions.cs index a1a68c31..74b563ca 100644 --- a/SabreTools.Library/IO/PathExtensions.cs +++ b/SabreTools.Library/IO/PathExtensions.cs @@ -39,7 +39,7 @@ namespace SabreTools.Library.IO /// SHA-1 hash to get the path for /// Positive value representing the depth of the depot /// Subfolder path for the given hash - public static string GetRombaPath(string hash, int depth) + public static string GetDepotPath(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 diff --git a/SabreTools/Features/BaseFeature.cs b/SabreTools/Features/BaseFeature.cs index d79c2310..32b4fe7f 100644 --- a/SabreTools/Features/BaseFeature.cs +++ b/SabreTools/Features/BaseFeature.cs @@ -2661,8 +2661,6 @@ Some special strings that can be used: RegionList = GetList(features, RegionListValue), RemoveExtension = GetBoolean(features, RemoveExtensionsValue), ReplaceExtension = GetString(features, ReplaceExtensionStringValue), - Romba = GetBoolean(features, RombaValue), - RombaDepth = GetInt32(features, RombaDepthInt32Value), RootDir = GetString(features, RootStringValue), SceneDateStrip = GetBoolean(features, SceneDateStripValue), Type = GetBoolean(features, SuperdatValue) ? "SuperDAT" : null, @@ -2671,9 +2669,13 @@ Some special strings that can be used: Version = GetString(features, VersionStringValue), }; - // Set a reasonable default for the Romba depth - if (datHeader.RombaDepth == Int32.MinValue) - datHeader.RombaDepth = 4; + // Get the depot information + datHeader.InputDepot = new DepotInformation( + GetBoolean(features, DepotValue), + GetInt32(features, DepotDepthInt32Value)); + datHeader.OutputDepot = new DepotInformation( + GetBoolean(features, RombaValue), + GetInt32(features, RombaDepthInt32Value)); bool deprecated = GetBoolean(features, DeprecatedValue); foreach (string ot in GetList(features, OutputTypeListValue)) diff --git a/SabreTools/Features/Sort.cs b/SabreTools/Features/Sort.cs index ee8c3676..f725fe0d 100644 --- a/SabreTools/Features/Sort.cs +++ b/SabreTools/Features/Sort.cs @@ -62,27 +62,17 @@ namespace SabreTools.Features TreatAsFiles asFiles = GetTreatAsFiles(features); bool date = GetBoolean(features, AddDateValue); bool delete = GetBoolean(features, DeleteValue); - bool depot = GetBoolean(features, DepotValue); bool inverse = GetBoolean(features, InverseValue); bool quickScan = GetBoolean(features, QuickValue); - bool romba = GetBoolean(features, RombaValue); bool updateDat = GetBoolean(features, UpdateDatValue); var outputFormat = GetOutputFormat(features); - // Get optional depths - int depotDepth = 4; - if (features.ContainsKey(DepotDepthInt32Value)) - depotDepth = GetInt32(features, DepotDepthInt32Value); - int rombaDepth = 4; - if (features.ContainsKey(RombaDepthInt32Value)) - rombaDepth = GetInt32(features, RombaDepthInt32Value); - // If we have TorrentGzip output and the romba flag, update - if (romba && outputFormat == OutputFormat.TorrentGzip) + if (Header.OutputDepot.IsActive && outputFormat == OutputFormat.TorrentGzip) outputFormat = OutputFormat.TorrentGzipRomba; // If we hae TorrentXZ output and the romba flag, update - if (romba && outputFormat == OutputFormat.TorrentXZ) + if (Header.OutputDepot.IsActive && outputFormat == OutputFormat.TorrentXZ) outputFormat = OutputFormat.TorrentXZRomba; // Get a list of files from the input datfiles @@ -97,15 +87,19 @@ namespace SabreTools.Features DatFile datdata = DatFile.Create(); datdata.Parse(datfile, 99, keep: true); + // Set depot information + datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; + datdata.Header.OutputDepot = Header.OutputDepot.Clone() as DepotInformation; + // If we have overridden the header skipper, set it now if (!string.IsNullOrEmpty(Header.HeaderSkipper)) datdata.Header.HeaderSkipper = Header.HeaderSkipper; // If we have the depot flag, respect it - if (depot) - datdata.RebuildDepot(Inputs, depotDepth, rombaDepth, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat, updateDat); + if (Header.InputDepot.IsActive) + datdata.RebuildDepot(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat, updateDat); else - datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), rombaDepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); + datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); } } @@ -121,6 +115,10 @@ namespace SabreTools.Features datdata.Parse(datfile, 99, keep: true); } + // Set depot information + datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; + datdata.Header.OutputDepot = Header.OutputDepot.Clone() as DepotInformation; + // If we have overridden the header skipper, set it now if (!string.IsNullOrEmpty(Header.HeaderSkipper)) datdata.Header.HeaderSkipper = Header.HeaderSkipper; @@ -128,10 +126,10 @@ namespace SabreTools.Features watch.Stop(); // If we have the depot flag, respect it - if (depot) - datdata.RebuildDepot(Inputs, depotDepth, rombaDepth, OutputDir, date, delete, inverse, outputFormat, updateDat); + if (Header.InputDepot.IsActive) + datdata.RebuildDepot(Inputs, OutputDir, date, delete, inverse, outputFormat, updateDat); else - datdata.RebuildGeneric(Inputs, OutputDir, rombaDepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); + datdata.RebuildGeneric(Inputs, OutputDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles); } } } diff --git a/SabreTools/Features/Verify.cs b/SabreTools/Features/Verify.cs index fa32d5fd..21882a3a 100644 --- a/SabreTools/Features/Verify.cs +++ b/SabreTools/Features/Verify.cs @@ -44,15 +44,9 @@ namespace SabreTools.Features // Get feature flags TreatAsFiles asFiles = GetTreatAsFiles(features); - bool depot = GetBoolean(features, DepotValue); bool hashOnly = GetBoolean(features, HashOnlyValue); bool quickScan = GetBoolean(features, QuickValue); - // Get optional depth - int depotDepth = 4; - if (features.ContainsKey(DepotDepthInt32Value)) - depotDepth = GetInt32(features, DepotDepthInt32Value); - // If we are in individual mode, process each DAT on their own if (GetBoolean(features, IndividualValue)) { @@ -62,13 +56,16 @@ namespace SabreTools.Features datdata.Parse(datfile, 99, keep: true); datdata.ApplyFilter(Filter, true); + // Set depot information + datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; + // If we have overridden the header skipper, set it now if (!string.IsNullOrEmpty(Header.HeaderSkipper)) datdata.Header.HeaderSkipper = Header.HeaderSkipper; // If we have the depot flag, respect it - if (depot) - datdata.VerifyDepot(Inputs, depotDepth, OutputDir); + if (Header.InputDepot.IsActive) + datdata.VerifyDepot(Inputs, OutputDir); else datdata.VerifyGeneric(Inputs, OutputDir, hashOnly, quickScan, asFiles, Filter); } @@ -86,6 +83,9 @@ namespace SabreTools.Features datdata.ApplyFilter(Filter, true); } + // Set depot information + datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; + // If we have overridden the header skipper, set it now if (!string.IsNullOrEmpty(Header.HeaderSkipper)) datdata.Header.HeaderSkipper = Header.HeaderSkipper; @@ -93,8 +93,8 @@ namespace SabreTools.Features watch.Stop(); // If we have the depot flag, respect it - if (depot) - datdata.VerifyDepot(Inputs, depotDepth, OutputDir); + if (Header.InputDepot.IsActive) + datdata.VerifyDepot(Inputs, OutputDir); else datdata.VerifyGeneric(Inputs, OutputDir, hashOnly, quickScan, asFiles, Filter); }