mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Don't need inplace all over anymore
This commit is contained in:
@@ -4768,19 +4768,19 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Split and write the DAT
|
// Split and write the DAT
|
||||||
if ((splittingMode & SplittingMode.Extension) != 0)
|
if ((splittingMode & SplittingMode.Extension) != 0)
|
||||||
{
|
{
|
||||||
SplitByExtension(outDir, inplace, exta, extb);
|
SplitByExtension(outDir, exta, extb);
|
||||||
}
|
}
|
||||||
if ((splittingMode & SplittingMode.Hash) != 0)
|
if ((splittingMode & SplittingMode.Hash) != 0)
|
||||||
{
|
{
|
||||||
SplitByHash(outDir, inplace);
|
SplitByHash(outDir);
|
||||||
}
|
}
|
||||||
if ((splittingMode & SplittingMode.Level) != 0)
|
if ((splittingMode & SplittingMode.Level) != 0)
|
||||||
{
|
{
|
||||||
SplitByLevel(outDir, inplace, shortname, basedat);
|
SplitByLevel(outDir, shortname, basedat);
|
||||||
}
|
}
|
||||||
if ((splittingMode & SplittingMode.Type) != 0)
|
if ((splittingMode & SplittingMode.Type) != 0)
|
||||||
{
|
{
|
||||||
SplitByType(outDir, inplace);
|
SplitByType(outDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now re-empty the DAT to make room for the next one
|
// Now re-empty the DAT to make room for the next one
|
||||||
@@ -4795,11 +4795,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Split a DAT by input extensions
|
/// Split a DAT by input extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||||
/// <param name="inplace">True if files should be written to the source folders, false otherwise</param>
|
|
||||||
/// <param name="extA">List of extensions to split on (first DAT)</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="extB">List of extensions to split on (second DAT)</param>
|
||||||
/// <returns>True if split succeeded, false otherwise</returns>
|
/// <returns>True if split succeeded, false otherwise</returns>
|
||||||
public bool SplitByExtension(string outDir, bool inplace, List<string> extA, List<string> extB)
|
public bool SplitByExtension(string outDir, List<string> extA, List<string> extB)
|
||||||
{
|
{
|
||||||
// Make sure all of the extensions have a dot at the beginning
|
// Make sure all of the extensions have a dot at the beginning
|
||||||
List<string> newExtA = new List<string>();
|
List<string> newExtA = new List<string>();
|
||||||
@@ -4877,9 +4876,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the output directory
|
|
||||||
outDir = Utilities.GetOutputPath(outDir, FileName, inplace);
|
|
||||||
|
|
||||||
// Then write out both files
|
// Then write out both files
|
||||||
bool success = datdataA.WriteToFile(outDir);
|
bool success = datdataA.WriteToFile(outDir);
|
||||||
success &= datdataB.WriteToFile(outDir);
|
success &= datdataB.WriteToFile(outDir);
|
||||||
@@ -4891,9 +4887,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Split a DAT by best available hashes
|
/// Split a DAT by best available hashes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||||
/// <param name="inplace">True if files should be written to the source folders, false otherwise</param>
|
|
||||||
/// <returns>True if split succeeded, false otherwise</returns>
|
/// <returns>True if split succeeded, false otherwise</returns>
|
||||||
public bool SplitByHash(string outDir, bool inplace)
|
public bool SplitByHash(string outDir)
|
||||||
{
|
{
|
||||||
// Create each of the respective output DATs
|
// Create each of the respective output DATs
|
||||||
Globals.Logger.User("Creating and populating new DATs");
|
Globals.Logger.User("Creating and populating new DATs");
|
||||||
@@ -5127,9 +5122,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the output directory
|
|
||||||
outDir = Utilities.GetOutputPath(outDir, FileName, inplace);
|
|
||||||
|
|
||||||
// Now, output all of the files to the output directory
|
// Now, output all of the files to the output directory
|
||||||
Globals.Logger.User("DAT information created, outputting new files");
|
Globals.Logger.User("DAT information created, outputting new files");
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -5148,11 +5140,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Split a SuperDAT by lowest available directory level
|
/// Split a SuperDAT by lowest available directory level
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||||
/// <param name="inplace">True if files should be written to the source folders, false otherwise</param>
|
|
||||||
/// <param name="shortname">True if short names should be used, false otherwise</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="basedat">True if original filenames should be used as the base for output filename, false otherwise</param>
|
||||||
/// <returns>True if split succeeded, false otherwise</returns>
|
/// <returns>True if split succeeded, false otherwise</returns>
|
||||||
public bool SplitByLevel(string outDir, bool inplace, bool shortname, bool basedat)
|
public bool SplitByLevel(string outDir, bool shortname, bool basedat)
|
||||||
{
|
{
|
||||||
// First, organize by games so that we can do the right thing
|
// First, organize by games so that we can do the right thing
|
||||||
BucketBy(SortedBy.Game, DedupeType.None, lower: false, norename: true);
|
BucketBy(SortedBy.Game, DedupeType.None, lower: false, norename: true);
|
||||||
@@ -5173,9 +5164,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Here, the key is the name of the game to be used for comparison
|
// Here, the key is the name of the game to be used for comparison
|
||||||
if (tempDat.Name != null && tempDat.Name != Path.GetDirectoryName(key))
|
if (tempDat.Name != null && tempDat.Name != Path.GetDirectoryName(key))
|
||||||
{
|
{
|
||||||
// Process and output the DAT
|
|
||||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat, inplace);
|
|
||||||
|
|
||||||
// Reset the DAT for the next items
|
// Reset the DAT for the next items
|
||||||
tempDat = new DatFile(this)
|
tempDat = new DatFile(this)
|
||||||
{
|
{
|
||||||
@@ -5195,9 +5183,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
tempDat.Name = Path.GetDirectoryName(key);
|
tempDat.Name = Path.GetDirectoryName(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Then we write the last DAT out since it would be skipped otherwise
|
|
||||||
SplitByLevelHelper(tempDat, outDir, shortname, basedat, inplace);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5227,16 +5212,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="outDir">Directory to write out to</param>
|
/// <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="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="restore">True if original filenames should be used as the base for output filename, false otherwise</param>
|
||||||
/// <param name="inplace">True if files should be written to the source folders, false otherwise</param>
|
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, bool restore)
|
||||||
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, bool restore, bool inplace)
|
|
||||||
{
|
{
|
||||||
// Get the name from the DAT to use separately
|
// Get the name from the DAT to use separately
|
||||||
string name = datFile.Name;
|
string name = datFile.Name;
|
||||||
string expName = name.Replace("/", " - ").Replace("\\", " - ");
|
string expName = name.Replace("/", " - ").Replace("\\", " - ");
|
||||||
|
|
||||||
// Get the output directory
|
|
||||||
outDir = Utilities.GetOutputPath(outDir, FileName, inplace);
|
|
||||||
|
|
||||||
// Now set the new output values
|
// Now set the new output values
|
||||||
datFile.FileName = HttpUtility.HtmlDecode(String.IsNullOrWhiteSpace(name)
|
datFile.FileName = HttpUtility.HtmlDecode(String.IsNullOrWhiteSpace(name)
|
||||||
? FileName
|
? FileName
|
||||||
@@ -5258,9 +5239,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Split a DAT by type of Rom
|
/// Split a DAT by type of Rom
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||||
/// <param name="inplace">True if files should be written to the source folders, false otherwise</param>
|
|
||||||
/// <returns>True if split succeeded, false otherwise</returns>
|
/// <returns>True if split succeeded, false otherwise</returns>
|
||||||
public bool SplitByType(string outDir, bool inplace)
|
public bool SplitByType(string outDir)
|
||||||
{
|
{
|
||||||
// Create each of the respective output DATs
|
// Create each of the respective output DATs
|
||||||
Globals.Logger.User("Creating and populating new DATs");
|
Globals.Logger.User("Creating and populating new DATs");
|
||||||
@@ -5353,9 +5333,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the output directory
|
|
||||||
outDir = Utilities.GetOutputPath(outDir, FileName, inplace);
|
|
||||||
|
|
||||||
// Now, output all of the files to the output directory
|
// Now, output all of the files to the output directory
|
||||||
Globals.Logger.User("DAT information created, outputting new files");
|
Globals.Logger.User("DAT information created, outputting new files");
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user