diff --git a/RombaSharp/Features/Archive.cs b/RombaSharp/Features/Archive.cs
index b153e2de..ca6281c8 100644
--- a/RombaSharp/Features/Archive.cs
+++ b/RombaSharp/Features/Archive.cs
@@ -66,8 +66,8 @@ have a current entry in the DAT index.";
foreach (string dir in onlyDirs)
{
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
- df.PopulateFromDir(dir, Hash.DeepHashes, false, false, SkipFileType.None, false, false, _tmpdir, false, true, null);
- df.PopulateFromDir(dir, Hash.DeepHashes, false, true, SkipFileType.None, false, false, _tmpdir, false, true, null);
+ df.PopulateFromDir(dir, Hash.DeepHashes, false, false, SkipFileType.None, false, false, false, true, null);
+ df.PopulateFromDir(dir, Hash.DeepHashes, false, true, SkipFileType.None, false, false, false, true, null);
}
// Create an empty Dat for files that need to be rebuilt
diff --git a/RombaSharp/Features/BaseFeature.cs b/RombaSharp/Features/BaseFeature.cs
index 7479c570..838b49f8 100644
--- a/RombaSharp/Features/BaseFeature.cs
+++ b/RombaSharp/Features/BaseFeature.cs
@@ -350,7 +350,6 @@ namespace RombaSharp.Features
// General settings
internal static string _logdir; // Log folder location
- internal static string _tmpdir; // Temp folder location
internal static string _webdir; // Web frontend location
internal static string _baddir; // Fail-to-unpack file folder location
internal static int _verbosity; // Verbosity of the output
@@ -588,7 +587,7 @@ namespace RombaSharp.Features
// Finally set all of the fields
Globals.MaxThreads = workers;
_logdir = logdir;
- _tmpdir = tmpdir;
+ Globals.TempDir = tmpdir;
_webdir = webdir;
_baddir = baddir;
_verbosity = verbosity;
diff --git a/RombaSharp/Features/Dir2Dat.cs b/RombaSharp/Features/Dir2Dat.cs
index 11215ebe..247a7f32 100644
--- a/RombaSharp/Features/Dir2Dat.cs
+++ b/RombaSharp/Features/Dir2Dat.cs
@@ -55,7 +55,7 @@ namespace RombaSharp.Features
// Now run the D2D on the input and write out
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
datfile.PopulateFromDir(source, Hash.DeepHashes, true /* bare */, false /* archivesAsFiles */, SkipFileType.None, false /* addBlanks */,
- false /* addDate */, _tmpdir, false /* copyFiles */, true /* chdsAsFiles */, null /* filter */);
+ false /* addDate */, false /* copyFiles */, true /* chdsAsFiles */, null /* filter */);
datfile.Write(outDir: outdat);
}
}
diff --git a/RombaSharp/Features/RefreshDats.cs b/RombaSharp/Features/RefreshDats.cs
index 2e7f29c1..80cb20f7 100644
--- a/RombaSharp/Features/RefreshDats.cs
+++ b/RombaSharp/Features/RefreshDats.cs
@@ -64,7 +64,7 @@ contents of any changed dats.";
datroot.Header.Type = "SuperDAT";
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
- datroot.PopulateFromDir(_dats, Hash.DeepHashes, false, false, SkipFileType.None, false, false, _tmpdir, false, true, null);
+ datroot.PopulateFromDir(_dats, Hash.DeepHashes, false, false, SkipFileType.None, false, false, false, true, null);
datroot.Items.BucketBy(BucketedBy.SHA1, DedupeType.None);
// Create a List of dat hashes in the database (SHA-1)
diff --git a/RombaSharp/Features/RescanDepots.cs b/RombaSharp/Features/RescanDepots.cs
index abd26c5e..2e481cfa 100644
--- a/RombaSharp/Features/RescanDepots.cs
+++ b/RombaSharp/Features/RescanDepots.cs
@@ -66,7 +66,7 @@ namespace RombaSharp.Features
DatFile depot = DatFile.Create();
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
- depot.PopulateFromDir(depotname, Hash.DeepHashes, false, false, SkipFileType.None, false, false, _tmpdir, false, true, null);
+ depot.PopulateFromDir(depotname, Hash.DeepHashes, false, false, SkipFileType.None, false, false, false, true, null);
depot.Items.BucketBy(BucketedBy.SHA1, DedupeType.None);
// Set the base queries to use
diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index dac59fec..4c7d0027 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -1491,7 +1491,6 @@ namespace SabreTools.Library.DatFiles
/// Type of files that should be skipped
/// True if blank items should be created for empty folders, false otherwise
/// True if dates should be archived for all files, false otherwise
- /// Name of the directory to create a temp folder in (blank is current directory)
/// Output directory to
/// True if files should be copied to the temp directory before hashing, false otherwise
/// True if CHDs should be treated like regular files, false otherwise
@@ -1505,7 +1504,6 @@ namespace SabreTools.Library.DatFiles
SkipFileType skipFileType,
bool addBlanks,
bool addDate,
- string tempDir,
bool copyFiles,
bool chdsAsFiles,
Filter filter,
@@ -1532,7 +1530,7 @@ namespace SabreTools.Library.DatFiles
}
// Clean the temp directory path
- tempDir = DirectoryExtensions.Ensure(tempDir, temp: true);
+ Globals.TempDir = DirectoryExtensions.Ensure(Globals.TempDir, temp: true);
// Process the input
if (Directory.Exists(basePath))
@@ -1544,7 +1542,7 @@ namespace SabreTools.Library.DatFiles
Parallel.ForEach(files, Globals.ParallelOptions, item =>
{
CheckFileForHashes(item, basePath, omitFromScan, archivesAsFiles, skipFileType,
- addBlanks, addDate, tempDir, copyFiles, chdsAsFiles);
+ addBlanks, addDate, copyFiles, chdsAsFiles);
});
// Now find all folders that are empty, if we are supposed to
@@ -1586,13 +1584,13 @@ namespace SabreTools.Library.DatFiles
else if (File.Exists(basePath))
{
CheckFileForHashes(basePath, Path.GetDirectoryName(Path.GetDirectoryName(basePath)), omitFromScan, archivesAsFiles,
- skipFileType, addBlanks, addDate, tempDir, copyFiles, chdsAsFiles);
+ skipFileType, addBlanks, addDate, copyFiles, chdsAsFiles);
}
// Now that we're done, delete the temp folder (if it's not the default)
Globals.Logger.User("Cleaning temp folder");
- if (tempDir != Path.GetTempPath())
- DirectoryExtensions.TryDelete(tempDir);
+ if (Globals.TempDir != Path.GetTempPath())
+ DirectoryExtensions.TryDelete(Globals.TempDir);
// If we have a valid filter, perform the filtering now
if (filter != null && filter != default(Filter))
@@ -1611,7 +1609,6 @@ namespace SabreTools.Library.DatFiles
/// Type of files that should be skipped
/// True if blank items should be created for empty folders, false otherwise
/// True if dates should be archived for all files, false otherwise
- /// Name of the directory to create a temp folder in (blank is current directory)
/// True if files should be copied to the temp directory before hashing, false otherwise
/// True if CHDs should be treated like regular files, false otherwise
private void CheckFileForHashes(
@@ -1622,7 +1619,6 @@ namespace SabreTools.Library.DatFiles
SkipFileType skipFileType,
bool addBlanks,
bool addDate,
- string tempDir,
bool copyFiles,
bool chdsAsFiles)
{
@@ -1654,7 +1650,7 @@ namespace SabreTools.Library.DatFiles
string newBasePath = basePath;
if (copyFiles)
{
- newBasePath = Path.Combine(tempDir, Guid.NewGuid().ToString());
+ newBasePath = Path.Combine(Globals.TempDir, Guid.NewGuid().ToString());
newItem = Path.GetFullPath(Path.Combine(newBasePath, Path.GetFullPath(item).Remove(0, basePath.Length + 1)));
DirectoryExtensions.TryCreateDirectory(Path.GetDirectoryName(newItem));
File.Copy(item, newItem, true);
@@ -2601,7 +2597,7 @@ namespace SabreTools.Library.DatFiles
{
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
PopulateFromDir(input, (quickScan ? Hash.SecureHashes : Hash.DeepHashes) /* omitFromScan */, true /* bare */, false /* archivesAsFiles */,
- SkipFileType.None, false /* addBlanks */, false /* addDate */, string.Empty /* tempDir */, false /* copyFiles */, chdsAsFiles, filter);
+ SkipFileType.None, false /* addBlanks */, false /* addDate */, false /* copyFiles */, chdsAsFiles, filter);
}
// Setup the fixdat
diff --git a/SabreTools.Library/Data/Globals.cs b/SabreTools.Library/Data/Globals.cs
index 910798d0..09fb72a0 100644
--- a/SabreTools.Library/Data/Globals.cs
+++ b/SabreTools.Library/Data/Globals.cs
@@ -20,6 +20,24 @@ namespace SabreTools.Library.Data
#region Public accessors
+ ///
+ /// Command line arguments passed in to the parent program
+ ///
+ public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
+
+ ///
+ /// Directory path for the current executable
+ ///
+ public static string ExeDir => Path.GetDirectoryName(ExeName);
+
+ ///
+ /// File path for the current executable
+ ///
+ public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
+
+ ///
+ /// Logging object for writing to file and console
+ ///
public static Logger Logger
{
get
@@ -32,18 +50,23 @@ namespace SabreTools.Library.Data
set { _logger = value; }
}
+ ///
+ /// Maximum threads to use during parallel operations
+ ///
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
+ ///
+ /// ParallelOptions object for use in parallel operations
+ ///
public static ParallelOptions ParallelOptions => new ParallelOptions()
{
MaxDegreeOfParallelism = MaxThreads
};
- public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
-
- public static string ExeDir => Path.GetDirectoryName(ExeName);
-
- public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
+ ///
+ /// Temporary directory location
+ ///
+ public static string TempDir { get; set; } = Path.GetTempPath();
#endregion
}
diff --git a/SabreTools/Features/BaseFeature.cs b/SabreTools/Features/BaseFeature.cs
index 95395f20..76a0aad2 100644
--- a/SabreTools/Features/BaseFeature.cs
+++ b/SabreTools/Features/BaseFeature.cs
@@ -2365,6 +2365,10 @@ Some special strings that can be used:
// Set threading flag, if necessary
if (features.ContainsKey(ThreadsInt32Value))
Globals.MaxThreads = GetInt32(features, ThreadsInt32Value);
+
+ // Set temp path, if necessary
+ if (features.ContainsKey(TempStringValue))
+ Globals.TempDir = GetString(features, TempStringValue);
}
#region Protected Specific Extraction
diff --git a/SabreTools/Features/DatFromDir.cs b/SabreTools/Features/DatFromDir.cs
index f8870bfb..b99d7bb3 100644
--- a/SabreTools/Features/DatFromDir.cs
+++ b/SabreTools/Features/DatFromDir.cs
@@ -60,7 +60,6 @@ namespace SabreTools.Features
bool chdsAsFiles = GetBoolean(features, ChdsAsFilesValue);
bool copyFiles = GetBoolean(features, CopyFilesValue);
bool noAutomaticDate = GetBoolean(features, NoAutomaticDateValue);
- string tempDir = GetString(features, TempStringValue);
var omitFromScan = GetOmitFromScan(features);
var skipFileType = GetSkipFileType(features);
@@ -85,7 +84,6 @@ namespace SabreTools.Features
skipFileType,
addBlankFiles,
addFileDates,
- tempDir,
copyFiles,
chdsAsFiles,
Filter);