diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs
index 3e1220c1..ee92d7bd 100644
--- a/SabreTools.Helper/Data/Build.cs
+++ b/SabreTools.Helper/Data/Build.cs
@@ -110,31 +110,7 @@ namespace SabreTools.Helper
helptext.Add(" -system= System name (system only)");
helptext.Add(" -source= Source name (source only)");
helptext.Add(" -url= URL (source only)");
- helptext.Add(" -d, --dfd Create a DAT from each input directory");
- helptext.Add(" -nm, --noMD5 Don't include MD5 in output");
- helptext.Add(" -ns, --noSHA1 Don't include SHA1 in output");
- helptext.Add(" -b, --bare Don't include date in file name");
- helptext.Add(" -u, --unzip Force unzipping in created DAT");
- helptext.Add(" -f, --files Treat archives as files");
- helptext.Add(" -oc, --output-cmp Output in CMP format");
- helptext.Add(" -om, --output-miss Output in Missfile format");
- helptext.Add(" -omd5, --output-md5 Output in MD5 format");
- helptext.Add(" -or, --output-rc Output in RomCenter format");
- helptext.Add(" -os, --output-sd Output in SabreDAT format");
- helptext.Add(" -osfv, --ouput-sfv Output in SFV format");
- helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format");
- helptext.Add(" -ox, --output-xml Output in Logiqx XML format");
- helptext.Add(" -gz, --gz-files Allow reading of GZIP files as archives");
- helptext.Add(" -ro, --romba Read files from a Romba input");
- helptext.Add(" -f=, --filename= Set the external name of the DAT");
- helptext.Add(" -n=, --name= Set the internal name of the DAT");
- helptext.Add(" -de=, --desc= Set the description of the DAT");
- helptext.Add(" -c=, --cat= Set the category of the DAT");
- helptext.Add(" -v=, --version= Set the version of the DAT");
- helptext.Add(" -au=, --author= Set the author of the DAT");
- helptext.Add(" -sd, --superdat Enable SuperDAT creation");
- helptext.Add(" -t=, --temp= Set the temporary directory to use");
- helptext.Add(" -dp, --dfdp Create a DAT using multithreading");
+ helptext.Add(" -d, --dfd Create a DAT from an input directory");
helptext.Add(" -nm, --noMD5 Don't include MD5 in output");
helptext.Add(" -ns, --noSHA1 Don't include SHA1 in output");
helptext.Add(" -b, --bare Don't include date in file name");
diff --git a/SabreTools.Helper/Objects/SimpleSort.cs b/SabreTools.Helper/Objects/SimpleSort.cs
index 3f6b9f43..59389213 100644
--- a/SabreTools.Helper/Objects/SimpleSort.cs
+++ b/SabreTools.Helper/Objects/SimpleSort.cs
@@ -543,7 +543,7 @@ namespace SabreTools.Helper
else
{
string archiveFileName = Path.Combine(_outdir, found.Machine.Name + ".zip");
- FileTools.CopyFileBetweenManagedArchives(input, archiveFileName, rom.Name, found.Name, _logger);
+ FileTools.CopyFileBetweenArchives(input, archiveFileName, rom.Name, found.Name, _logger);
}
}
}
diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST
index 8ac2d6b6..d2717aac 100644
--- a/SabreTools.Helper/README.1ST
+++ b/SabreTools.Helper/README.1ST
@@ -234,97 +234,12 @@ Options:
Optionally, a temp folder can be supplied in the case the default temp directory
(inside the running folder) is not preferred. This is used for any operations
that require an archive to be extracted.
-
- -dp, --dfdp Create a DAT from each input directory using parallel code
- Create a DAT file from an input directory or set of files. By default, this will
- output a DAT named based on the input directory and the current date. It will also
- treat all archives as possible games and add all three hashes for each file.
-
- -nm, --noMD5 Don't include MD5 in output
- This allows the user to skip calculating the MD5 for each of the files which will
- speed up the creation of the DAT.
-
- -ns, --noSHA1 Don't include SHA1 in output
- This allows the user to skip calculating the SHA-1 for each of the files which will
- speed up the creation of the DAT.
-
- -b, --bare Don't include date in file name
- Normally, the DAT will be created with the date in the file name. This flag removes
- that but keeps the date tag intact.
-
- -u, --unzip Force unzipping in created DAT
- This sets the 'forcepacking="unzip"' flag in the outputted DAT. When used with a
- file manager that allows for it, this will force the outputted files to be in
- subdirectories instead of archives.
-
- -f, --files Treat archives as files
- Instead of trying to enumerate the files within archives, treat the archives as
- files themselves. This is good for uncompressed sets that include archives that
- should be read as-is.
-
- -oc, --output-cmp Output in CMP format
- Add outputting the created DAT to clrmamepro format
-
- -om, --output-miss Output in Missfile format
- Add outputting the created DAT to GoodTools miss format
-
- -omd5, --output-md5 Output in MD5 format
- Add outputting the created DAT to MD5 format
-
- -or, --output-rc Output in RomCenter format
- Add outputting the created DAT to RomCenter format
-
- -os, --output-sd Output in SabreDAT format
- Add outputting the created DAT to SabreDAT XML format
-
- -osfv, --ouput-sfv Output in SFV format
- Add outputting the created DAT to SFV format
-
- -osha1, --output-sha1 Output in SHA-1 format
- Add outputting the created DAT to SHA1 format
-
- -ox, --output-xml Output in Logiqx XML format (default)
- Add outputting the created DAT to Logiqx XML format
-
- -gz, --gz-files Allow reading of GZIP files as archives
- Since GZip files are not commonly used for file storage, this flag allows for
- any GZip archives to have their contents hashed instead.
-
- -ro, --romba Read files from a Romba input
- Allow for reading of GZipped files as if they were from a Romba depot. This
- implies that the files will be in the TorrentGZ format as well, including
- naming convention.
-
- -f=, --filename= Set the external name of the DAT
- Set the base filename for the output DAT(s) [default is folder name plus date]
-
- -n=, --name= Set the internal name of the DAT
- Set the internal name for the output DAT(s) [default is folder name plus date]
-
- -de=, --desc= Set the description of the DAT
- Set the description for the output DAT(s) [default is the folder name]
-
- -c=, --cat= Set the category of the DAT
- Set the category for the output DAT(s) [default is blank]
-
- -v=, --version= Set the version of the DAT
- Set the version for the output DAT(s) [default is blank]
-
- -au=, --author= Set the author of the DAT
- Set the author for the output DAT(s) [default is blank]
-
- -sd, --superdat Enable SuperDAT creation
- Set the type flag to "SuperDAT" for the output DAT as well as preserving the
- directory structure of the inputted folder, if applicable
-
- -t=, --temp= Set the name of the temporary directory
- Optionally, a temp folder can be supplied in the case the default temp directory
- (inside the running folder) is not preferred. This is used for any operations
- that require an archive to be extracted.
-mt={4} Amount of threads to use
Optionally, set the number of threads to use for the multithreaded operations.
- The default is 4 threads; -1 means unlimited threads created.
+ The default is 4 threads; -1 means unlimited threads created. If the user specifies
+ that only 1 thread is to be used, it defaults to the original, serial implementation
+ of the DFD code.
-es, --ext-split Split a DAT by two file extensions
For a DAT, or set of DATs, allow for splitting based on a list of input extensions.
diff --git a/SabreTools.Helper/Tools/FileTools.cs b/SabreTools.Helper/Tools/FileTools.cs
index 0b44ddf8..89446a0f 100644
--- a/SabreTools.Helper/Tools/FileTools.cs
+++ b/SabreTools.Helper/Tools/FileTools.cs
@@ -422,80 +422,6 @@ namespace SabreTools.Helper
#region Archive-to-Archive Handling
- ///
- /// Attempt to copy a file between archives
- ///
- /// Source archive name
- /// Destination archive name
- /// Input entry name
- /// Output entry name
- /// Logger object for file and console output
- /// True if the copy was a success, false otherwise
- public static bool CopyFileBetweenArchives(string inputArchive, string outputArchive,
- string sourceEntryName, string destEntryName, Logger logger)
- {
- bool success = false;
-
- // First get the archive types
- ArchiveType? iat = GetCurrentArchiveType(inputArchive, logger);
- ArchiveType? oat = (File.Exists(outputArchive) ? GetCurrentArchiveType(outputArchive, logger) : ArchiveType.Zip);
-
- // If we got back null (or the output is not a Zipfile), then it's not an archive, so we we return
- if (iat == null || (oat == null || oat != ArchiveType.Zip) || inputArchive == outputArchive)
- {
- return success;
- }
-
- IReader reader = null;
- ZipArchive outarchive = null;
- try
- {
- reader = ReaderFactory.Open(File.OpenRead(inputArchive));
-
- if (iat == ArchiveType.Zip || iat == ArchiveType.SevenZip || iat == ArchiveType.Rar)
- {
- while (reader.MoveToNextEntry())
- {
- logger.Log("Current entry name: '" + reader.Entry.Key + "'");
- if (reader.Entry != null && reader.Entry.Key.Contains(sourceEntryName))
- {
- if (!File.Exists(outputArchive))
- {
- outarchive = ZipFile.Open(outputArchive, ZipArchiveMode.Create);
- }
- else
- {
- outarchive = ZipFile.Open(outputArchive, ZipArchiveMode.Update);
- }
-
- if (outarchive.Mode == ZipArchiveMode.Create || outarchive.GetEntry(destEntryName) == null)
- {
- ZipArchiveEntry iae = outarchive.CreateEntry(destEntryName, CompressionLevel.Optimal) as ZipArchiveEntry;
-
- using (Stream iaestream = iae.Open())
- {
- reader.WriteEntryTo(iaestream);
- }
- }
- success = true;
- }
- }
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex.ToString());
- success = false;
- }
- finally
- {
- reader?.Dispose();
- outarchive?.Dispose();
- }
-
- return success;
- }
-
///
/// Attempt to copy a file between archives using SharpCompress
///
@@ -505,7 +431,7 @@ namespace SabreTools.Helper
/// Output entry name
/// Logger object for file and console output
/// True if the copy was a success, false otherwise
- public static bool CopyFileBetweenManagedArchives(string inputArchive, string outputArchive,
+ public static bool CopyFileBetweenArchives(string inputArchive, string outputArchive,
string sourceEntryName, string destEntryName, Logger logger)
{
bool success = false;
diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs
index 7897dbb0..dc782588 100644
--- a/SabreTools/Partials/SabreTools_Inits.cs
+++ b/SabreTools/Partials/SabreTools_Inits.cs
@@ -82,72 +82,6 @@ namespace SabreTools
return ss.Convert();
}
- ///
- /// Wrap creating a DAT file from files or a directory
- ///
- /// List of innput filenames
- /// New filename
- /// New name
- /// New description
- /// New category
- /// New version
- /// New author
- /// True to set forcepacking="unzip" on the created file, false otherwise
- /// OutputFormat to be used for outputting the DAT
- /// True to enable reading a directory like a Romba depot, false otherwise
- /// True to enable SuperDAT-style reading, false otherwise
- /// True to disable getting MD5 hash, false otherwise
- /// True to disable getting SHA-1 hash, false otherwise
- /// True if the date should be omitted from the DAT, false otherwise
- /// True if archives should be treated as files, false otherwise
- /// True if GZIP archives should be treated as files, false otherwise
- /// Name of the directory to create a temp folder in (blank is current directory
- private static void InitDatFromDir(List inputs,
- string filename,
- string name,
- string description,
- string category,
- string version,
- string author,
- bool forceunpack,
- OutputFormat outputFormat,
- bool romba,
- bool superdat,
- bool noMD5,
- bool noSHA1,
- bool bare,
- bool archivesAsFiles,
- bool enableGzip,
- string tempDir)
- {
- // Create a new DATFromDir object and process the inputs
- Dat datdata = new Dat
- {
- FileName = filename,
- Name = name,
- Description = description,
- Category = category,
- Version = version,
- Date = DateTime.Now.ToString("yyyy-MM-dd"),
- Author = author,
- ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
- OutputFormat = (outputFormat == 0 ? OutputFormat.Xml : outputFormat),
- Romba = romba,
- Type = (superdat ? "SuperDAT" : ""),
- Files = new Dictionary>(),
- };
-
- DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger);
- bool success = dfd.Start();
-
- // If we failed, show the help
- if (!success)
- {
- Console.WriteLine();
- Build.Help();
- }
- }
-
///
/// Wrap creating a DAT file from files or a directory in parallel
///
@@ -169,7 +103,7 @@ namespace SabreTools
/// True if GZIP archives should be treated as files, false otherwise
/// Name of the directory to create a temp folder in (blank is current directory
/// Integer representing the maximum amount of parallelization to be used
- private static void InitDatFromDirParallel(List inputs,
+ private static void InitDatFromDir(List inputs,
string filename,
string name,
string description,
@@ -204,30 +138,48 @@ namespace SabreTools
Type = (superdat ? "SuperDAT" : ""),
};
- // For each input directory, create a DAT
- foreach (string path in inputs)
+ // If the user has only set a single thread, use the original version
+ if (maxDegreeOfParallelism == 1)
{
- if (Directory.Exists(path))
+ DATFromDir dfd = new DATFromDir(inputs, basedat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger);
+ bool success = dfd.Start();
+
+ // If we failed, show the help
+ if (!success)
{
- // Clone the base Dat for information
- Dat datdata = (Dat)basedat.Clone();
- datdata.Files = new Dictionary>();
-
- string basePath = Path.GetFullPath(path);
- DATFromDirParallel dfd = new DATFromDirParallel(basePath, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, maxDegreeOfParallelism, _logger);
- bool success = dfd.Start();
-
- // If it was a success, write the DAT out
- if (success)
+ Console.WriteLine();
+ Build.Help();
+ }
+ }
+
+ // Otherwise, make full use of the threads
+ else
+ {
+ // For each input directory, create a DAT
+ foreach (string path in inputs)
+ {
+ if (Directory.Exists(path))
{
- DatTools.WriteDatfile(dfd.DatData, "", _logger);
- }
+ // Clone the base Dat for information
+ Dat datdata = (Dat)basedat.Clone();
+ datdata.Files = new Dictionary>();
- // Otherwise, show the help
- else
- {
- Console.WriteLine();
- Build.Help();
+ string basePath = Path.GetFullPath(path);
+ DATFromDirParallel dfd = new DATFromDirParallel(basePath, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, maxDegreeOfParallelism, _logger);
+ bool success = dfd.Start();
+
+ // If it was a success, write the DAT out
+ if (success)
+ {
+ DatTools.WriteDatfile(dfd.DatData, "", _logger);
+ }
+
+ // Otherwise, show the help
+ else
+ {
+ Console.WriteLine();
+ Build.Help();
+ }
}
}
}
diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs
index 060ae7a2..74adf1cb 100644
--- a/SabreTools/SabreTools.cs
+++ b/SabreTools/SabreTools.cs
@@ -81,7 +81,6 @@ namespace SabreTools
bare = false,
clean = false,
datfromdir = false,
- datfromdirparallel = false,
datprefix = false,
dedup = false,
enableGzip = false,
@@ -238,11 +237,6 @@ namespace SabreTools
case "--diff-nd":
diffMode |= DiffMode.NoDupes;
break;
- case "-dp":
- case "--d2dp":
- case "--dfdp":
- datfromdirparallel = true;
- break;
case "-es":
case "--ext-split":
extsplit = true;
@@ -624,7 +618,7 @@ namespace SabreTools
}
// If more than one switch is enabled, show the help screen
- if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ headerer ^ import ^ listsrc ^
+ if (!(add ^ datfromdir ^ extsplit ^ generate ^ genall ^ hashsplit ^ headerer ^ import ^ listsrc ^
listsys ^ (merge || diffMode != 0 || update || outputFormat != 0 || tsv != null|| trim) ^ rem ^ stats ^ typesplit))
{
_logger.Error("Only one feature switch is allowed at a time");
@@ -634,7 +628,7 @@ namespace SabreTools
}
// If a switch that requires a filename is set and no file is, show the help screen
- if (inputs.Count == 0 && (datfromdir || datfromdirparallel || extsplit || hashsplit || headerer
+ if (inputs.Count == 0 && (datfromdir || extsplit || hashsplit || headerer
|| (merge || diffMode != 0 || update || outputFormat != 0 || tsv != null) || stats || trim || typesplit))
{
_logger.Error("This feature requires at least one input");
@@ -666,13 +660,6 @@ namespace SabreTools
else if (datfromdir)
{
InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
- romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir);
- }
-
- // Create a DAT from a directory or set of directories in parallel
- else if (datfromdirparallel)
- {
- InitDatFromDirParallel(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir, maxParallelism);
}