mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Globals] Add global variables to be used everywhere
This commit is contained in:
@@ -26,10 +26,8 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="basepath">Parent path for replacement</param>
|
||||
/// <param name="extA">List of extensions to split on (first DAT)</param>
|
||||
/// <param name="extB">List of extensions to split on (second DAT)</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for console and file writing</param>
|
||||
/// <returns>True if split succeeded, false otherwise</returns>
|
||||
public bool SplitByExt(string outDir, string basepath, List<string> extA, List<string> extB, int maxDegreeOfParallelism, Logger logger)
|
||||
public bool SplitByExt(string outDir, string basepath, List<string> extA, List<string> extB)
|
||||
{
|
||||
// Make sure all of the extensions have a dot at the beginning
|
||||
List<string> newExtA = new List<string>();
|
||||
@@ -116,8 +114,8 @@ namespace SabreTools.Helper.Dats
|
||||
}
|
||||
|
||||
// Then write out both files
|
||||
bool success = datdataA.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= datdataB.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
bool success = datdataA.WriteToFile(outDir);
|
||||
success &= datdataB.WriteToFile(outDir);
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -127,16 +125,14 @@ namespace SabreTools.Helper.Dats
|
||||
/// </summary>
|
||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||
/// <param name="basepath">Parent path for replacement</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for console and file writing</param>
|
||||
/// <returns>True if split succeeded, false otherwise</returns>
|
||||
public bool SplitByHash(string outDir, string basepath, int maxDegreeOfParallelism, Logger logger)
|
||||
public bool SplitByHash(string outDir, string basepath)
|
||||
{
|
||||
// Sanitize the basepath to be more predictable
|
||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||
|
||||
// Create each of the respective output DATs
|
||||
logger.User("Creating and populating new DATs");
|
||||
Globals.Logger.User("Creating and populating new DATs");
|
||||
DatFile nodump = new DatFile
|
||||
{
|
||||
FileName = this.FileName + " (Nodump)",
|
||||
@@ -299,12 +295,12 @@ namespace SabreTools.Helper.Dats
|
||||
}
|
||||
|
||||
// Now, output all of the files to the output directory
|
||||
logger.User("DAT information created, outputting new files");
|
||||
Globals.Logger.User("DAT information created, outputting new files");
|
||||
bool success = true;
|
||||
success &= nodump.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= sha1.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= md5.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= crc.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= nodump.WriteToFile(outDir);
|
||||
success &= sha1.WriteToFile(outDir);
|
||||
success &= md5.WriteToFile(outDir);
|
||||
success &= crc.WriteToFile(outDir);
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -316,16 +312,14 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="basepath">Parent path for replacement</param>
|
||||
/// <param name="shortname">True if short names should be used, false otherwise</param>
|
||||
/// <param name="basedat">True if original filenames should be used as the base for output filename, false otherwise</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for console and file writing</param>
|
||||
/// <returns>True if split succeeded, false otherwise</returns>
|
||||
public bool SplitByLevel(string outDir, string basepath, bool shortname, bool basedat, int maxDegreeOfParallelism, Logger logger)
|
||||
public bool SplitByLevel(string outDir, string basepath, bool shortname, bool basedat)
|
||||
{
|
||||
// Sanitize the basepath to be more predictable
|
||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||
|
||||
// First, organize by games so that we can do the right thing
|
||||
BucketBy(SortedBy.Game, false /* mergeroms */, maxDegreeOfParallelism, logger, lower: false, norename: true);
|
||||
BucketBy(SortedBy.Game, false /* mergeroms */, lower: false, norename: true);
|
||||
|
||||
// Create a temporary DAT to add things to
|
||||
DatFile tempDat = new DatFile(this)
|
||||
@@ -344,7 +338,7 @@ namespace SabreTools.Helper.Dats
|
||||
if (tempDat.Name != null && tempDat.Name != Style.GetDirectoryName(key))
|
||||
{
|
||||
// Process and output the DAT
|
||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat, maxDegreeOfParallelism, logger);
|
||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat);
|
||||
|
||||
// Reset the DAT for the next items
|
||||
tempDat = new DatFile(this)
|
||||
@@ -366,7 +360,7 @@ namespace SabreTools.Helper.Dats
|
||||
}
|
||||
|
||||
// Then we write the last DAT out since it would be skipped otherwise
|
||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat, maxDegreeOfParallelism, logger);
|
||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -397,9 +391,7 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="outDir">Directory to write out to</param>
|
||||
/// <param name="shortname">True if short naming scheme should be used, false otherwise</param>
|
||||
/// <param name="restore">True if original filenames should be used as the base for output filename, false otherwise</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, bool restore, int maxDegreeOfParallelism, Logger logger)
|
||||
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, bool restore)
|
||||
{
|
||||
// Get the name from the DAT to use separately
|
||||
string name = datFile.Name;
|
||||
@@ -424,7 +416,7 @@ namespace SabreTools.Helper.Dats
|
||||
datFile.Type = null;
|
||||
|
||||
// Write out the temporary DAT to the proper directory
|
||||
datFile.WriteToFile(path, maxDegreeOfParallelism, logger);
|
||||
datFile.WriteToFile(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -432,16 +424,14 @@ namespace SabreTools.Helper.Dats
|
||||
/// </summary>
|
||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||
/// <param name="basepath">Parent path for replacement</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for console and file writing</param>
|
||||
/// <returns>True if split succeeded, false otherwise</returns>
|
||||
public bool SplitByType(string outDir, string basepath, int maxDegreeOfParallelism, Logger logger)
|
||||
public bool SplitByType(string outDir, string basepath)
|
||||
{
|
||||
// Sanitize the basepath to be more predictable
|
||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||
|
||||
// Create each of the respective output DATs
|
||||
logger.User("Creating and populating new DATs");
|
||||
Globals.Logger.User("Creating and populating new DATs");
|
||||
DatFile romdat = new DatFile
|
||||
{
|
||||
FileName = this.FileName + " (ROM)",
|
||||
@@ -542,11 +532,11 @@ namespace SabreTools.Helper.Dats
|
||||
}
|
||||
|
||||
// Now, output all of the files to the output directory
|
||||
logger.User("DAT information created, outputting new files");
|
||||
Globals.Logger.User("DAT information created, outputting new files");
|
||||
bool success = true;
|
||||
success &= romdat.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= diskdat.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= sampledat.WriteToFile(outDir, maxDegreeOfParallelism, logger);
|
||||
success &= romdat.WriteToFile(outDir);
|
||||
success &= diskdat.WriteToFile(outDir);
|
||||
success &= sampledat.WriteToFile(outDir);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user