Add and use DepotInformation

This commit is contained in:
Matt Nadareski
2020-08-20 11:23:48 -07:00
parent c5a7cb9d17
commit 3e320bb85e
11 changed files with 165 additions and 114 deletions

View File

@@ -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);

View File

@@ -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<string> 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
/// </summary>
/// <param name="inputs">List of input files/folders to check</param>
/// <param name="indepth">Positive value representing depth of input depot</param>
/// <param name="outdepth">Positive value representing depth of output depot</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
/// <param name="delete">True if input files should be deleted, false otherwise</param>
@@ -2353,8 +2351,6 @@ namespace SabreTools.Library.DatFiles
/// <returns>True if rebuilding was a success, false otherwise</returns>
public bool RebuildDepot(
List<string> 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
/// </summary>
/// <param name="inputs">List of input files/folders to check</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="outdepth">Positive value representing depth of output depot</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
/// <param name="delete">True if input files should be deleted, false otherwise</param>
@@ -2538,7 +2533,6 @@ namespace SabreTools.Library.DatFiles
public bool RebuildGeneric(
List<string> 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
/// </summary>
/// <param name="file">Name of the file to process</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="outdepth">Positive value representing depth of output depot</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
/// <param name="delete">True if input files should be deleted, false otherwise</param>
@@ -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
/// <param name="datItem">Information for the current file to rebuild from</param>
/// <param name="file">Name of the file to process</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="outdepth">Positive value representing depth of output depot</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
/// <param name="inverse">True if the DAT should be used as a filter instead of a template, false otherwise</param>
/// <param name="outputFormat">Output format that files should be written to</param>
@@ -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
/// </summary>
/// <param name="inputs">List of input directories to compare against</param>
/// <param name="depth">Positive value representing depot depth, defaults to 4</param>
/// <param name="outDir">Optional param for output directory</param>
/// <returns>True if verification was a success, false otherwise</returns>
public bool VerifyDepot(List<string> inputs, int depth = 4, string outDir = null)
public bool VerifyDepot(List<string> 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;
}
}

View File

@@ -211,16 +211,16 @@ namespace SabreTools.Library.DatFiles
public bool RemoveExtension { get; set; }
/// <summary>
/// Romba output mode
/// Input depot information
/// </summary>
[JsonIgnore]
public bool Romba { get; set; }
public DepotInformation InputDepot { get; set; }
/// <summary>
/// Romba depth
/// Output depot information
/// </summary>
[JsonIgnore]
public int RombaDepth { get; set; } = 4;
public DepotInformation OutputDepot { get; set; }
/// <summary>
/// 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

View File

@@ -0,0 +1,60 @@
using System;
using SabreTools.Library.Data;
namespace SabreTools.Library.DatFiles
{
public class DepotInformation : ICloneable
{
/// <summary>
/// Name or path of the Depot
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Whether to use this Depot or not
/// </summary>
public bool IsActive { get; private set; }
/// <summary>
/// Depot byte-depth
/// </summary>
public int Depth { get; private set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="isActive">Set active state</param>
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
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
/// <summary>
/// Clone the current object
/// </summary>
public object Clone()
{
return new DepotInformation
{
Name = this.Name,
IsActive = this.IsActive,
Depth = this.Depth,
};
}
#endregion
}
}

View File

@@ -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");
}

View File

@@ -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)))

View File

@@ -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

View File

@@ -39,7 +39,7 @@ namespace SabreTools.Library.IO
/// <param name="hash">SHA-1 hash to get the path for</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, 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

View File

@@ -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))

View File

@@ -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);
}
}
}

View File

@@ -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);
}