mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Replace RVX with Depth
This commit is contained in:
@@ -2103,7 +2103,7 @@ namespace SabreTools.Library.DatFiles
|
||||
});
|
||||
|
||||
// Now find all folders that are empty, if we are supposed to
|
||||
if (Header.Romba == null && addBlanks)
|
||||
if (!Header.Romba && addBlanks)
|
||||
{
|
||||
List<string> empties = DirectoryExtensions.ListEmpty(basePath);
|
||||
Parallel.ForEach(empties, Globals.ParallelOptions, dir =>
|
||||
@@ -2177,8 +2177,8 @@ namespace SabreTools.Library.DatFiles
|
||||
bool addDate,
|
||||
bool copyFiles)
|
||||
{
|
||||
// Special case for if we are in Romba or RVX mode (all names are supposed to be SHA-1 hashes)
|
||||
if (Header.Romba != null)
|
||||
// Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
|
||||
if (Header.Romba)
|
||||
{
|
||||
GZipArchive gzarc = new GZipArchive(item);
|
||||
BaseFile baseFile = gzarc.GetTorrentGZFileInfo();
|
||||
@@ -2400,8 +2400,8 @@ 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="romroot">True to build from 2-deep, false to default to 4-deep</param>
|
||||
/// <param name="rvx">True to only go to 2-deep, false to default to 4-deep</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>
|
||||
@@ -2411,8 +2411,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <returns>True if rebuilding was a success, false otherwise</returns>
|
||||
public bool RebuildDepot(
|
||||
List<string> inputs,
|
||||
bool romroot = false,
|
||||
bool rvx = false,
|
||||
int indepth = 4,
|
||||
int outdepth = 4,
|
||||
string outDir = null,
|
||||
bool date = false,
|
||||
bool delete = false,
|
||||
@@ -2521,7 +2521,7 @@ namespace SabreTools.Library.DatFiles
|
||||
Globals.Logger.User($"Checking hash '{hash}'");
|
||||
|
||||
// Get the extension path for the hash
|
||||
string subpath = PathExtensions.GetRombaPath(hash, romroot);
|
||||
string subpath = PathExtensions.GetRombaPath(hash, indepth);
|
||||
|
||||
// Find the first depot that includes the hash
|
||||
string foundpath = null;
|
||||
@@ -2553,9 +2553,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, rvx, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, outdepth, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
else
|
||||
usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, rvx, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, outdepth, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
|
||||
// If we are supposed to delete the depot file, do so
|
||||
if (delete && usedInternally)
|
||||
@@ -2584,7 +2584,7 @@ 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="rvx">True to only go to 2-deep, false to default to 4-deep</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>
|
||||
@@ -2596,7 +2596,7 @@ namespace SabreTools.Library.DatFiles
|
||||
public bool RebuildGeneric(
|
||||
List<string> inputs,
|
||||
string outDir = null,
|
||||
bool rvx = false,
|
||||
int outdepth = 4,
|
||||
bool quickScan = false,
|
||||
bool date = false,
|
||||
bool delete = false,
|
||||
@@ -2684,7 +2684,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (File.Exists(input))
|
||||
{
|
||||
Globals.Logger.User($"Checking file: {input}");
|
||||
RebuildGenericHelper(input, outDir, rvx, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
|
||||
RebuildGenericHelper(input, outDir, outdepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
|
||||
}
|
||||
|
||||
// If the input is a directory
|
||||
@@ -2694,7 +2694,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
Globals.Logger.User($"Checking file: {file}");
|
||||
RebuildGenericHelper(file, outDir, rvx, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
|
||||
RebuildGenericHelper(file, outDir, outdepth, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2721,7 +2721,7 @@ 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="rvx">True to only go to 2-deep, false to default to 4-deep</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>
|
||||
@@ -2732,7 +2732,7 @@ namespace SabreTools.Library.DatFiles
|
||||
private void RebuildGenericHelper(
|
||||
string file,
|
||||
string outDir,
|
||||
bool rvx,
|
||||
int outdepth,
|
||||
bool quickScan,
|
||||
bool date,
|
||||
bool delete,
|
||||
@@ -2760,7 +2760,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (externalFileInfo.Type == FileType.None)
|
||||
externalDatItem = new Rom(externalFileInfo);
|
||||
|
||||
usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, null /* isZip */);
|
||||
usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, null /* isZip */);
|
||||
|
||||
// Scan the file internally
|
||||
|
||||
@@ -2793,7 +2793,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (internalFileInfo.Type == FileType.None)
|
||||
internalDatItem = new Rom(internalFileInfo);
|
||||
|
||||
usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, null /* isZip */);
|
||||
usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, null /* isZip */);
|
||||
}
|
||||
// Otherwise, loop through the entries and try to match
|
||||
else
|
||||
@@ -2801,7 +2801,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (BaseFile entry in entries)
|
||||
{
|
||||
DatItem internalDatItem = DatItem.Create(entry);
|
||||
usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */);
|
||||
usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, outdepth, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2816,7 +2816,7 @@ 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="rvx">True to only go to 2-deep, false to default to 4-deep</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>
|
||||
@@ -2827,7 +2827,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem datItem,
|
||||
string file,
|
||||
string outDir,
|
||||
bool rvx,
|
||||
int outdepth,
|
||||
bool date,
|
||||
bool inverse,
|
||||
OutputFormat outputFormat,
|
||||
@@ -2869,7 +2869,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Get the proper output path
|
||||
if (outputFormat == OutputFormat.TorrentGzipRomba)
|
||||
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, rvx));
|
||||
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, outdepth));
|
||||
else
|
||||
outDir = Path.Combine(outDir, sha1 + ".gz");
|
||||
|
||||
@@ -2897,7 +2897,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Get the proper output path
|
||||
if (outputFormat == OutputFormat.TorrentXZRomba)
|
||||
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, rvx));
|
||||
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, outdepth));
|
||||
else
|
||||
outDir = Path.Combine(outDir, sha1 + ".xz");
|
||||
|
||||
@@ -2969,13 +2969,8 @@ namespace SabreTools.Library.DatFiles
|
||||
// Get the output archive, if possible
|
||||
Folder outputArchive = Folder.Create(outputFormat);
|
||||
|
||||
// Get the romba value
|
||||
bool? romba = null;
|
||||
if (outputFormat == OutputFormat.TorrentGzipRomba || outputFormat == OutputFormat.TorrentXZRomba)
|
||||
romba = rvx;
|
||||
|
||||
// Now rebuild to the output file
|
||||
outputArchive.Write(fileStream, outDir, (Rom)item, date: date, romba: romba);
|
||||
outputArchive.Write(fileStream, outDir, (Rom)item, date: date, depth: outdepth);
|
||||
}
|
||||
|
||||
// Close the input stream
|
||||
@@ -3041,14 +3036,9 @@ namespace SabreTools.Library.DatFiles
|
||||
// Get the output archive, if possible
|
||||
Folder outputArchive = Folder.Create(outputFormat);
|
||||
|
||||
// Get the romba value
|
||||
bool? romba = null;
|
||||
if (outputFormat == OutputFormat.TorrentGzipRomba || outputFormat == OutputFormat.TorrentXZRomba)
|
||||
romba = rvx;
|
||||
|
||||
// Now rebuild to the output file
|
||||
eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, romba: romba);
|
||||
eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, romba: romba);
|
||||
eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, depth: outdepth);
|
||||
eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, depth: outdepth);
|
||||
|
||||
// Now add the success of either rebuild
|
||||
rebuilt &= eitherSuccess;
|
||||
@@ -3071,10 +3061,10 @@ 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="rvx">True to only go to 2-deep, false to default to 4-deep</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, bool rvx = false, string outDir = null)
|
||||
public bool VerifyDepot(List<string> inputs, int depth = 4, string outDir = null)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
@@ -3110,7 +3100,7 @@ namespace SabreTools.Library.DatFiles
|
||||
Globals.Logger.User($"Checking hash '{hash}'");
|
||||
|
||||
// Get the extension path for the hash
|
||||
string subpath = PathExtensions.GetRombaPath(hash, rvx);
|
||||
string subpath = PathExtensions.GetRombaPath(hash, depth);
|
||||
|
||||
// Find the first depot that includes the hash
|
||||
string foundpath = null;
|
||||
@@ -3792,7 +3782,7 @@ namespace SabreTools.Library.DatFiles
|
||||
string post = CreatePrefixPostfix(item, false);
|
||||
|
||||
// If we're in Romba mode, take care of that instead
|
||||
if (Header.Romba == true)
|
||||
if (Header.Romba)
|
||||
{
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
@@ -3801,7 +3791,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.Romba == false).Replace('\\', '/');
|
||||
name = PathExtensions.GetRombaPath(romItem.SHA1, Header.RombaDepth).Replace('\\', '/');
|
||||
item.Name = $"{pre}{name}{post}";
|
||||
}
|
||||
}
|
||||
@@ -3812,36 +3802,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.Romba == false).Replace('\\', '/');
|
||||
item.Name = pre + name + post;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're in RVX mode, take care of that instead
|
||||
if (Header.Romba == false)
|
||||
{
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
Rom romItem = item as Rom;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(romItem.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetRombaPath(romItem.SHA1, Header.Romba == false).Replace('\\', '/');
|
||||
item.Name = $"{pre}{name}{post}";
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
Disk diskItem = item as Disk;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(diskItem.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetRombaPath(diskItem.SHA1, Header.Romba == false).Replace('\\', '/');
|
||||
name = PathExtensions.GetRombaPath(diskItem.SHA1, Header.RombaDepth).Replace('\\', '/');
|
||||
item.Name = pre + name + post;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user