Add RVX compatible inputs

This commit is contained in:
Matt Nadareski
2020-08-18 11:34:43 -07:00
parent 381183c71c
commit 8e687a251d
22 changed files with 233 additions and 102 deletions

View File

@@ -62,6 +62,8 @@ structure according to the original DAT master directory tree structure.";
// Now scan all of those depots and rebuild
datFile.RebuildDepot(
onlineDepots,
romroot: false,
rvx: false,
outDir: outputFolder,
outputFormat: (copy ? OutputFormat.TorrentGzipRomba : OutputFormat.TorrentZip),
updateDat: false);

View File

@@ -2103,7 +2103,7 @@ namespace SabreTools.Library.DatFiles
});
// Now find all folders that are empty, if we are supposed to
if (!Header.Romba && addBlanks)
if (Header.Romba == null && 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 mode (all names are supposed to be SHA-1 hashes)
if (Header.Romba)
// Special case for if we are in Romba or RVX mode (all names are supposed to be SHA-1 hashes)
if (Header.Romba != null)
{
GZipArchive gzarc = new GZipArchive(item);
BaseFile baseFile = gzarc.GetTorrentGZFileInfo();
@@ -2400,6 +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="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>
@@ -2409,6 +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,
string outDir = null,
bool date = false,
bool delete = false,
@@ -2517,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);
string subpath = PathExtensions.GetRombaPath(hash, romroot);
// Find the first depot that includes the hash
string foundpath = null;
@@ -2549,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, date, inverse, outputFormat, updateDat, false /* isZip */);
usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, rvx, date, inverse, outputFormat, updateDat, false /* isZip */);
else
usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, rvx, date, inverse, outputFormat, updateDat, false /* isZip */);
// If we are supposed to delete the depot file, do so
if (delete && usedInternally)
@@ -2580,6 +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="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>
@@ -2591,6 +2596,7 @@ namespace SabreTools.Library.DatFiles
public bool RebuildGeneric(
List<string> inputs,
string outDir = null,
bool rvx = false,
bool quickScan = false,
bool date = false,
bool delete = false,
@@ -2678,7 +2684,7 @@ namespace SabreTools.Library.DatFiles
if (File.Exists(input))
{
Globals.Logger.User($"Checking file: {input}");
RebuildGenericHelper(input, outDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
RebuildGenericHelper(input, outDir, rvx, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
}
// If the input is a directory
@@ -2688,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, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
RebuildGenericHelper(file, outDir, rvx, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
}
}
}
@@ -2715,6 +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="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>
@@ -2725,6 +2732,7 @@ namespace SabreTools.Library.DatFiles
private void RebuildGenericHelper(
string file,
string outDir,
bool rvx,
bool quickScan,
bool date,
bool delete,
@@ -2752,7 +2760,7 @@ namespace SabreTools.Library.DatFiles
else if (externalFileInfo.Type == FileType.None)
externalDatItem = new Rom(externalFileInfo);
usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, date, inverse, outputFormat, updateDat, null /* isZip */);
usedExternally = RebuildIndividualFile(externalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, null /* isZip */);
// Scan the file internally
@@ -2785,7 +2793,7 @@ namespace SabreTools.Library.DatFiles
else if (internalFileInfo.Type == FileType.None)
internalDatItem = new Rom(internalFileInfo);
usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, null /* isZip */);
usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, null /* isZip */);
}
// Otherwise, loop through the entries and try to match
else
@@ -2793,7 +2801,7 @@ namespace SabreTools.Library.DatFiles
foreach (BaseFile entry in entries)
{
DatItem internalDatItem = DatItem.Create(entry);
usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */);
usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, rvx, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */);
}
}
@@ -2808,6 +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="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>
@@ -2818,6 +2827,7 @@ namespace SabreTools.Library.DatFiles
DatItem datItem,
string file,
string outDir,
bool rvx,
bool date,
bool inverse,
OutputFormat outputFormat,
@@ -2859,7 +2869,7 @@ namespace SabreTools.Library.DatFiles
// Get the proper output path
if (outputFormat == OutputFormat.TorrentGzipRomba)
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1));
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, rvx));
else
outDir = Path.Combine(outDir, sha1 + ".gz");
@@ -2886,8 +2896,8 @@ namespace SabreTools.Library.DatFiles
Globals.Logger.User($"Matches found for '{Path.GetFileName(datItem.Name)}', rebuilding accordingly...");
// Get the proper output path
if (outputFormat == OutputFormat.TorrentGzipRomba)
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1));
if (outputFormat == OutputFormat.TorrentXZRomba)
outDir = Path.Combine(outDir, PathExtensions.GetRombaPath(sha1, rvx));
else
outDir = Path.Combine(outDir, sha1 + ".xz");
@@ -2959,8 +2969,13 @@ 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: outputFormat == OutputFormat.TorrentGzipRomba || outputFormat == OutputFormat.TorrentXZRomba);
outputArchive.Write(fileStream, outDir, (Rom)item, date: date, romba: romba);
}
// Close the input stream
@@ -3026,9 +3041,14 @@ 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: outputFormat == OutputFormat.TorrentGzipRomba || outputFormat == OutputFormat.TorrentXZRomba);
eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, romba: outputFormat == OutputFormat.TorrentGzipRomba || outputFormat == OutputFormat.TorrentXZRomba);
eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, romba: romba);
eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, romba: romba);
// Now add the success of either rebuild
rebuilt &= eitherSuccess;
@@ -3051,9 +3071,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="outDir">Optional param for output directory</param>
/// <returns>True if verification was a success, false otherwise</returns>
public bool VerifyDepot(List<string> inputs, string outDir = null)
public bool VerifyDepot(List<string> inputs, bool rvx = false, string outDir = null)
{
bool success = true;
@@ -3089,7 +3110,7 @@ namespace SabreTools.Library.DatFiles
Globals.Logger.User($"Checking hash '{hash}'");
// Get the extension path for the hash
string subpath = PathExtensions.GetRombaPath(hash);
string subpath = PathExtensions.GetRombaPath(hash, rvx);
// Find the first depot that includes the hash
string foundpath = null;
@@ -3771,7 +3792,7 @@ namespace SabreTools.Library.DatFiles
string post = CreatePrefixPostfix(item, false);
// If we're in Romba mode, take care of that instead
if (Header.Romba)
if (Header.Romba == true)
{
if (item.ItemType == ItemType.Rom)
{
@@ -3780,7 +3801,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).Replace('\\', '/');
name = PathExtensions.GetRombaPath(romItem.SHA1, Header.Romba == false).Replace('\\', '/');
item.Name = $"{pre}{name}{post}";
}
}
@@ -3791,7 +3812,36 @@ 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).Replace('\\', '/');
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('\\', '/');
item.Name = pre + name + post;
}
}

View File

@@ -211,10 +211,11 @@ namespace SabreTools.Library.DatFiles
public bool RemoveExtension { get; set; }
/// <summary>
/// Romba output mode
/// Romba or RVX output mode
/// </summary>
/// <remarks>Null means neither, false means RVX, true means Romba</remarks>
[JsonIgnore]
public bool Romba { get; set; }
public bool? Romba { get; set; } = null;
/// <summary>
/// Output the machine name

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.Romba != null || Header.UseRomName)
{
sw.Write($"{datItem.GetField(Field.Name, Header.ExcludeFields)}\n");
}

View File

@@ -176,9 +176,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override abstract bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false);
public override abstract bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null);
/// <summary>
/// Write an input stream to an archive
@@ -187,9 +187,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override abstract bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false);
public override abstract bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null);
/// <summary>
/// Write a set of input files to an archive (assuming the same output archive name)

View File

@@ -293,10 +293,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public virtual bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public virtual bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
FileStream fs = FileExtensions.TryOpenRead(inputFile);
return Write(fs, outDir, rom, date, romba);
@@ -309,10 +309,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public virtual bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public virtual bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
bool success = false;

View File

@@ -411,10 +411,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom = null, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom = null, bool date = false, bool? romba = null)
{
// Check that the input file exists
if (!File.Exists(inputFile))
@@ -436,10 +436,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom = null, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom = null, bool date = false, bool? romba = null)
{
bool success = false;
@@ -459,16 +459,23 @@ namespace SabreTools.Library.FileTypes
// Get the output file name
string outfile;
// If we have a romba output, add the romba path
if (romba)
// If we have a Romba output, add the depot path
if (romba == true)
{
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1)); // TODO: When updating to SHA-256, this needs to update to SHA256
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, false)); // 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)))
{
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
}
// If we have an RVX output, add the RomRoot path
else if (romba == false)
{
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, true)); // 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)))
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
}
// Otherwise, we're just rebuilding to the main directory
else

View File

@@ -117,10 +117,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}
@@ -132,10 +132,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}

View File

@@ -117,10 +117,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}
@@ -132,10 +132,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}

View File

@@ -284,9 +284,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
// Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, romba);
@@ -299,9 +299,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}

View File

@@ -414,9 +414,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
// Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date);
@@ -429,9 +429,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");

View File

@@ -289,9 +289,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
// Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date);
@@ -304,9 +304,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");

View File

@@ -312,10 +312,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
// Check that the input file exists
if (!File.Exists(inputFile))
@@ -337,9 +337,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
bool success = false;
@@ -359,10 +359,19 @@ namespace SabreTools.Library.FileTypes
// Get the output file name
string outfile;
// If we have a romba output, add the romba path
if (romba)
// If we have a Romba output, add the depot path
if (romba == true)
{
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1)); // TODO: When updating to SHA-256, this needs to update to SHA256
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, false)); // 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)))
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
}
// If we have an RVX output, add the RomRoot path
else if (romba == false)
{
outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, true)); // 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

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Library.Data;
using SabreTools.Library.DatFiles;
using SabreTools.Library.DatItems;
@@ -117,10 +116,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}
@@ -132,10 +131,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}

View File

@@ -419,9 +419,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
// Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date);
@@ -434,9 +434,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");

View File

@@ -117,10 +117,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}
@@ -132,10 +132,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false for RVX RomRoot folders, null otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool? romba = null)
{
throw new NotImplementedException();
}

View File

@@ -37,13 +37,20 @@ namespace SabreTools.Library.IO
/// Get a proper romba sub path
/// </summary>
/// <param name="hash">SHA-1 hash to get the path for</param>
/// <param name="rvx">True to only go to 2-deep, false to default to 4-deep</param>
/// <returns>Subfolder path for the given hash</returns>
public static string GetRombaPath(string hash)
public static string GetRombaPath(string hash, bool rvx)
{
// 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
return null;
// RVX uses a 2-deep RomRoot
if (rvx)
return Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash + ".gz");
// Romba uses a 4-deep Depot
else
return Path.Combine(hash.Substring(0, 2), hash.Substring(2, 2), hash.Substring(4, 2), hash.Substring(6, 2), hash + ".gz");
}

View File

@@ -312,9 +312,9 @@ namespace SabreTools.Features
return new Feature(
DepotValue,
new List<string>() { "-dep", "--depot" },
"Assume directories are romba depots",
"Assume directories are Romba depots",
FeatureType.Flag,
longDescription: "Normally, input directories will be treated with no special format. If this flag is used, all input directories will be assumed to be romba-style depots.");
longDescription: "Normally, input directories will be treated with no special format. If this flag is used, all input directories will be assumed to be Romba-style depots.");
}
}
@@ -794,6 +794,20 @@ namespace SabreTools.Features
}
}
internal const string RomRootValue = "romroot";
internal static Feature RomRootFlag
{
get
{
return new Feature(
RomRootValue,
new List<string>() { "-rr", "--romroot" },
"Assume directories are RVX RomRoots",
FeatureType.Flag,
longDescription: "Normally, input directories will be treated with no special format. If this flag is used, all input directories will be assumed to be RVX-style RomRoots.");
}
}
internal const string RomsValue = "roms";
internal static Feature RomsFlag
{
@@ -822,6 +836,20 @@ namespace SabreTools.Features
}
}
internal const string RVXValue = "rvx";
internal static Feature RVXFlag
{
get
{
return new Feature(
RVXValue,
new List<string>() { "-rvx", "--romvaultx" },
"Treat like an RVX RomRoot (requires SHA-1)",
FeatureType.Flag,
longDescription: "This flag allows reading and writing of DATs and output files to and from a RVX-style RomRoot. This also implies TorrentGZ input and output for physical files.");
}
}
internal const string SceneDateStripValue = "scene-date-strip";
internal static Feature SceneDateStripFlag
{
@@ -2633,7 +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),
RootDir = GetString(features, RootStringValue),
SceneDateStrip = GetBoolean(features, SceneDateStripValue),
Type = GetBoolean(features, SuperdatValue) ? "SuperDAT" : null,
@@ -2642,6 +2669,12 @@ Some special strings that can be used:
Version = GetString(features, VersionStringValue),
};
// Romba overrides RVX for flags
if (GetBoolean(features, RombaValue))
datHeader.Romba = true;
else if (GetBoolean(features, RVXValue))
datHeader.Romba = false;
bool deprecated = GetBoolean(features, DeprecatedValue);
foreach (string ot in GetList(features, OutputTypeListValue))
{

View File

@@ -35,6 +35,7 @@ namespace SabreTools.Features
AddFeature(OutputTypeListInput);
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
AddFeature(RombaFlag);
AddFeature(RVXFlag);
AddFeature(SkipArchivesFlag);
AddFeature(SkipFilesFlag);
AddHeaderFeatures();

View File

@@ -25,6 +25,7 @@ namespace SabreTools.Features
AddFeature(DatListInput);
AddFeature(OutputDirStringInput);
AddFeature(DepotFlag);
AddFeature(RomRootFlag);
AddFeature(DeleteFlag);
AddFeature(InverseFlag);
AddFeature(QuickFlag);
@@ -37,6 +38,7 @@ namespace SabreTools.Features
AddFeature(TarFlag);
AddFeature(TorrentGzipFlag);
this[TorrentGzipFlag].AddFeature(RombaFlag);
this[TorrentGzipFlag].AddFeature(RVXFlag);
//AddFeature(SharedInputs.TorrentLrzipFlag);
//AddFeature(SharedInputs.TorrentLz4Flag);
//AddFeature(SharedInputs.TorrentRarFlag);
@@ -60,19 +62,31 @@ 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);
// Romba overrides RVX for flags
bool? romba = null;
if (GetBoolean(features, RombaValue))
romba = true;
else if (GetBoolean(features, RVXValue))
romba = false;
// Depot overrides RomRoot for flags
bool? depot = null;
if (GetBoolean(features, DepotValue))
depot = true;
else if (GetBoolean(features, RomRootValue))
depot = false;
// If we have TorrentGzip output and the romba flag, update
if (romba && outputFormat == OutputFormat.TorrentGzip)
if (romba != null && outputFormat == OutputFormat.TorrentGzip)
outputFormat = OutputFormat.TorrentGzipRomba;
// If we hae TorrentXZ output and the romba flag, update
if (romba && outputFormat == OutputFormat.TorrentXZ)
if (romba != null && outputFormat == OutputFormat.TorrentXZ)
outputFormat = OutputFormat.TorrentXZRomba;
// Get a list of files from the input datfiles
@@ -92,10 +106,10 @@ namespace SabreTools.Features
datdata.Header.HeaderSkipper = Header.HeaderSkipper;
// If we have the depot flag, respect it
if (depot)
datdata.RebuildDepot(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat, updateDat);
if (depot != null)
datdata.RebuildDepot(Inputs, depot == false, romba == false, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat, updateDat);
else
datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), romba == false, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
}
}
@@ -118,10 +132,10 @@ namespace SabreTools.Features
watch.Stop();
// If we have the depot flag, respect it
if (depot)
datdata.RebuildDepot(Inputs, OutputDir, date, delete, inverse, outputFormat, updateDat);
if (depot != null)
datdata.RebuildDepot(Inputs, depot == false, romba == false, OutputDir, date, delete, inverse, outputFormat, updateDat);
else
datdata.RebuildGeneric(Inputs, OutputDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
datdata.RebuildGeneric(Inputs, OutputDir, romba == false, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
}
}
}

View File

@@ -32,6 +32,7 @@ namespace SabreTools.Features
this[OutputTypeListInput].AddFeature(ReplaceExtensionStringInput);
this[OutputTypeListInput].AddFeature(RemoveExtensionsFlag);
this[OutputTypeListInput].AddFeature(RombaFlag);
this[OutputTypeListInput].AddFeature(RVXFlag);
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
AddHeaderFeatures();

View File

@@ -22,6 +22,7 @@ namespace SabreTools.Features
AddFeature(DatListInput);
AddFeature(DepotFlag);
AddFeature(RomRootFlag);
AddFeature(TempStringInput);
AddFeature(OutputDirStringInput);
AddFeature(HashOnlyFlag);
@@ -43,10 +44,16 @@ 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);
// Depot overrides RomRoot for flags
bool? depot = null;
if (GetBoolean(features, DepotValue))
depot = true;
else if (GetBoolean(features, RomRootValue))
depot = false;
// If we are in individual mode, process each DAT on their own
if (GetBoolean(features, IndividualValue))
{
@@ -61,8 +68,8 @@ namespace SabreTools.Features
datdata.Header.HeaderSkipper = Header.HeaderSkipper;
// If we have the depot flag, respect it
if (depot)
datdata.VerifyDepot(Inputs, OutputDir);
if (depot != null)
datdata.VerifyDepot(Inputs, depot == false, OutputDir);
else
datdata.VerifyGeneric(Inputs, OutputDir, hashOnly, quickScan, asFiles, Filter);
}
@@ -87,8 +94,8 @@ namespace SabreTools.Features
watch.Stop();
// If we have the depot flag, respect it
if (depot)
datdata.VerifyDepot(Inputs, OutputDir);
if (depot != null)
datdata.VerifyDepot(Inputs, depot == false, OutputDir);
else
datdata.VerifyGeneric(Inputs, OutputDir, hashOnly, quickScan, asFiles, Filter);
}