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:
@@ -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 for RVX RomRoot folders, null otherwise</param>
|
||||
/// <param name="depth">Positive value for depth of the output depot, defaults to 4</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 = null)
|
||||
public override bool Write(string inputFile, string outDir, Rom rom = null, bool date = false, int depth = 4)
|
||||
{
|
||||
// Check that the input file exists
|
||||
if (!File.Exists(inputFile))
|
||||
@@ -426,7 +426,7 @@ namespace SabreTools.Library.FileTypes
|
||||
inputFile = Path.GetFullPath(inputFile);
|
||||
|
||||
// Get the file stream for the file and write out
|
||||
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, romba);
|
||||
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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 for RVX RomRoot folders, null otherwise</param>
|
||||
/// <param name="depth">Positive value for depth of the output depot, defaults to 4</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 = null)
|
||||
public override bool Write(Stream inputStream, string outDir, Rom rom = null, bool date = false, int depth = 4)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
@@ -457,31 +457,11 @@ namespace SabreTools.Library.FileTypes
|
||||
rom = new Rom(inputStream.GetInfo(keepReadOpen: true));
|
||||
|
||||
// Get the output file name
|
||||
string outfile;
|
||||
string outfile = Path.Combine(outDir, PathExtensions.GetRombaPath(rom.SHA1, depth)); // TODO: When updating to SHA-256, this needs to update to SHA256
|
||||
|
||||
// If we have a Romba output, add the depot path
|
||||
if (romba == true)
|
||||
{
|
||||
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
|
||||
{
|
||||
outfile = Path.Combine(outDir, rom.SHA1 + ".gz"); // 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 the output file exists, don't try to write again
|
||||
if (!File.Exists(outfile))
|
||||
|
||||
Reference in New Issue
Block a user