mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFIle, Utilities] Order in the Force
So this change is deceptively simple but could help solve a lot of issues. First is that in most cases, the default is now that output DATs do not overwrite what is already in the current folder. This should be able to help in cases where multiple folders are being output to the same folder during updates. The second is that now, if the output path is the current directory AND there was a directory input, the lowest directory name is now used as a subfolder in the current directory. This helps get rid of even more issues when an output directory is not set.
This commit is contained in:
@@ -1598,7 +1598,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
||||||
|
|
||||||
// Once we're done, try writing out
|
// Once we're done, try writing out
|
||||||
intDat.Write(interOutDir);
|
intDat.Write(interOutDir, overwrite: inplace);
|
||||||
|
|
||||||
// Due to possible memory requirements, we force a garbage collection
|
// Due to possible memory requirements, we force a garbage collection
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
@@ -1657,7 +1657,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
||||||
|
|
||||||
// Once we're done, try writing out
|
// Once we're done, try writing out
|
||||||
intDat.Write(interOutDir);
|
intDat.Write(interOutDir, overwrite: inplace);
|
||||||
|
|
||||||
// Due to possible memory requirements, we force a garbage collection
|
// Due to possible memory requirements, we force a garbage collection
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
@@ -1681,15 +1681,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
InternalStopwatch watch = new InternalStopwatch("Initializing all output DATs");
|
InternalStopwatch watch = new InternalStopwatch("Initializing all output DATs");
|
||||||
|
|
||||||
DatFile[] outDatsArray = new DatFile[inputs.Count];
|
DatFile[] outDatsArray = new DatFile[inputs.Count];
|
||||||
|
|
||||||
// TODO: Make this smarter when there are multiple input directories specified
|
|
||||||
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
|
||||||
{
|
{
|
||||||
string innerpost = " (" + j + " - " + Utilities.GetFilenameFromFileAndParent(inputs[j], true) + " 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 or the output directory is set, take the appropriate DatData object already stored
|
||||||
if (inplace)
|
if (inplace || outDir != Environment.CurrentDirectory)
|
||||||
{
|
{
|
||||||
diffData = datHeaders[j];
|
diffData = datHeaders[j];
|
||||||
}
|
}
|
||||||
@@ -1748,7 +1746,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
string path = Utilities.GetOutputPath(outDir, inputs[j], inplace);
|
string path = Utilities.GetOutputPath(outDir, inputs[j], inplace);
|
||||||
|
|
||||||
// Try to output the file
|
// Try to output the file
|
||||||
outDats[j].Write(path);
|
outDats[j].Write(path, overwrite: inplace);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -1892,13 +1890,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Output the difflist (a-b)+(b-a) diff
|
// Output the difflist (a-b)+(b-a) diff
|
||||||
if ((diff & UpdateMode.DiffNoDupesOnly) != 0)
|
if ((diff & UpdateMode.DiffNoDupesOnly) != 0)
|
||||||
{
|
{
|
||||||
outerDiffData.Write(outDir);
|
outerDiffData.Write(outDir, overwrite: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the (ab) diff
|
// Output the (ab) diff
|
||||||
if ((diff & UpdateMode.DiffDupesOnly) != 0)
|
if ((diff & UpdateMode.DiffDupesOnly) != 0)
|
||||||
{
|
{
|
||||||
dupeData.Write(outDir);
|
dupeData.Write(outDir, overwrite: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the individual (a-b) DATs
|
// Output the individual (a-b) DATs
|
||||||
@@ -1909,7 +1907,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
string path = Utilities.GetOutputPath(outDir, inputs[j], false /* inplace */);
|
string path = Utilities.GetOutputPath(outDir, inputs[j], false /* inplace */);
|
||||||
|
|
||||||
// Try to output the file
|
// Try to output the file
|
||||||
outDats[j].Write(path);
|
outDats[j].Write(path, overwrite: false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1953,7 +1951,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to output the file
|
// Try to output the file
|
||||||
Write(outDir);
|
Write(outDir, overwrite: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1985,8 +1983,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
string realOutDir = Utilities.GetOutputPath(outDir, file, inplace);
|
string realOutDir = Utilities.GetOutputPath(outDir, file, inplace);
|
||||||
|
|
||||||
// Try to output the file, overwriting only if it's not in the current directory
|
// Try to output the file, overwriting only if it's not in the current directory
|
||||||
// TODO: Figure out if overwriting should always happen of if there should be a user flag
|
innerDatdata.Write(realOutDir, overwrite: inplace);
|
||||||
innerDatdata.Write(realOutDir, overwrite: (realOutDir != Environment.CurrentDirectory));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2721,6 +2721,13 @@ namespace SabreTools.Library.Tools
|
|||||||
outDir = Path.GetDirectoryName(split[1]);
|
outDir = Path.GetDirectoryName(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Should this be the default? Always create a subfolder if a folder is found?
|
||||||
|
// If we are processing a path that is coming from a directory and we are outputting to the current directory, we want to get the subfolder to write to
|
||||||
|
else if (split[0].Length != split[1].Length && outDir == Environment.CurrentDirectory)
|
||||||
|
{
|
||||||
|
outDir = Path.GetDirectoryName(Path.Combine(outDir, split[0].Remove(0, Path.GetDirectoryName(split[1]).Length + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
// If we are processing a path that is coming from a directory, we want to get the subfolder to write to
|
// If we are processing a path that is coming from a directory, we want to get the subfolder to write to
|
||||||
else if (split[0].Length != split[1].Length)
|
else if (split[0].Length != split[1].Length)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user