[DatFile] Add restore flag for level split

This commit is contained in:
Matt Nadareski
2016-10-31 14:55:51 -07:00
parent b7527ca174
commit 5e4f17f634
5 changed files with 121 additions and 116 deletions

View File

@@ -5026,9 +5026,10 @@ namespace SabreTools.Helper.Dats
/// <param name="outDir">Name of the directory to write the DATs out to</param>
/// <param name="basepath">Parent path for replacement</param>
/// <param name="shortname">True if short names 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="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, Logger logger)
public bool SplitByLevel(string outDir, string basepath, bool shortname, bool restore, Logger logger)
{
// Sanitize the basepath to be more predictable
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
@@ -5051,7 +5052,7 @@ namespace SabreTools.Helper.Dats
if (tempDat.Name != null && tempDat.Name != Style.GetDirectoryName(key))
{
// Process and output the DAT
SplitByLevelHelper(tempDat, outDir, shortname, logger);
SplitByLevelHelper(tempDat, outDir, shortname, restore, logger);
// Reset the DAT for the next items
tempDat = (DatFile)CloneHeader();
@@ -5078,7 +5079,7 @@ namespace SabreTools.Helper.Dats
}
// Then we write the last DAT out since it would be skipped otherwise
SplitByLevelHelper(tempDat, outDir, shortname, logger);
SplitByLevelHelper(tempDat, outDir, shortname, restore, logger);
return true;
}
@@ -5108,8 +5109,9 @@ namespace SabreTools.Helper.Dats
/// <param name="datFile">DAT to clean and write out</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="restore">True if original filenames should be used as the base for output filename, false otherwise</param>
/// <param name="logger">Logger object for file and console output</param>
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, Logger logger)
private void SplitByLevelHelper(DatFile datFile, string outDir, bool shortname, bool restore, Logger logger)
{
// Get the path that the file will be written out to
string path = HttpUtility.HtmlDecode(String.IsNullOrEmpty(datFile.Name)
@@ -5124,7 +5126,8 @@ namespace SabreTools.Helper.Dats
: datFile.Name.Replace("/", " - ").Replace("\\", " - ")
)
);
datFile.Description += " (" + datFile.Name.Replace("/", " - ").Replace("\\", " - ") + ")";
datFile.FileName = (restore ? FileName + " (" + datFile.FileName + ")" : datFile.FileName);
datFile.Description = Description + " (" + datFile.Name.Replace("/", " - ").Replace("\\", " - ") + ")";
datFile.Name = Name + " (" + datFile.Name.Replace("/", " - ").Replace("\\", " - ") + ")";
datFile.Type = null;