mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, Utilities] Use subpath where possible
Using the subpath in the name of the output file can sometimes help distinguish which verison of a file is being used if the numbering doesn't help.
This commit is contained in:
@@ -1684,7 +1684,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
||||||
{
|
{
|
||||||
string innerpost = " (" + j + " - " + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
string innerpost = " (" + j + " - " + Utilities.GetFilenameFromFileAndParent(inputs[j], true) + " Only)";
|
||||||
DatFile diffData;
|
DatFile diffData;
|
||||||
|
|
||||||
// If we're in inplace mode, take the appropriate DatData object already stored
|
// If we're in inplace mode, take the appropriate DatData object already stored
|
||||||
@@ -1816,7 +1816,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
||||||
{
|
{
|
||||||
string innerpost = " (" + j + " - " + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
string innerpost = " (" + j + " - " + Utilities.GetFilenameFromFileAndParent(inputs[j], true) + " Only)";
|
||||||
DatFile diffData = new DatFile(this);
|
DatFile diffData = new DatFile(this);
|
||||||
diffData.FileName += innerpost;
|
diffData.FileName += innerpost;
|
||||||
diffData.Name += innerpost;
|
diffData.Name += innerpost;
|
||||||
|
|||||||
@@ -2583,6 +2583,34 @@ namespace SabreTools.Library.Tools
|
|||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the proper filename (with subpath) from the file and parent combination
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Input combined path to use</param>
|
||||||
|
/// <param name="sanitize">True if path separators should be converted to '-', false otherwise</param>
|
||||||
|
/// <returns>Subpath for the file</returns>
|
||||||
|
public static string GetFilenameFromFileAndParent(string path, bool sanitize)
|
||||||
|
{
|
||||||
|
// Check that we have a combined path first
|
||||||
|
if (!path.Contains("¬"))
|
||||||
|
{
|
||||||
|
return Path.GetFileName(path).Replace('/', '-').Replace('\\', '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
// First separate out the parts
|
||||||
|
string child = path.Split('¬')[0];
|
||||||
|
string parent = path.Split('¬')[1];
|
||||||
|
|
||||||
|
// If the parts are the same, return the filename from the first part
|
||||||
|
if (child == parent)
|
||||||
|
{
|
||||||
|
return Path.GetFileName(child).Replace('/', '-').Replace('\\', '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, remove the parent from the child and return the remainder
|
||||||
|
return child.Remove(0, parent.Length + 1).Replace('/', '-').Replace('\\', '-');
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the dictionary key that should be used for a given item and sorting type
|
/// Get the dictionary key that should be used for a given item and sorting type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user