diff --git a/RombaSharp/Partials/RombaSharp_Inits.cs b/RombaSharp/Partials/RombaSharp_Inits.cs index b4ceda69..7a653c56 100644 --- a/RombaSharp/Partials/RombaSharp_Inits.cs +++ b/RombaSharp/Partials/RombaSharp_Inits.cs @@ -67,7 +67,7 @@ namespace SabreTools }; DATFromDir dfd = new DATFromDir(inputs, datdata, false /* noMD5 */, false /* noSHA1 */, true /* bare */, - false /* archivesAsFiles */, true /* enableGzip */, false /* addblanks */, "__temp__" /* tempdir */, _logger); + false /* archivesAsFiles */, true /* enableGzip */, false /* addBlanks */, false /* addDate */, "__temp__" /* tempdir */, _logger); dfd.Start(); } diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index f3be5032..833f33a1 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -133,6 +133,8 @@ namespace SabreTools.Helper 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(" -ab, --add-blank Output blank files for folders"); + helptext.Add(" -ad, --add-date Output dates for each file parsed"); helptext.Add(" -t=, --temp= Set the temporary directory to use"); helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)"); helptext.Add(" -es, --ext-split Split a DAT by two file extensions"); diff --git a/SabreTools.Helper/Objects/DATFromDir.cs b/SabreTools.Helper/Objects/DATFromDir.cs index bde179f6..89011b0f 100644 --- a/SabreTools.Helper/Objects/DATFromDir.cs +++ b/SabreTools.Helper/Objects/DATFromDir.cs @@ -25,7 +25,8 @@ namespace SabreTools private bool _bare; private bool _archivesAsFiles; private bool _enableGzip; - private bool _addblanks; + private bool _addBlanks; + private bool _addDate; private bool _nowrite; // Other required variables @@ -47,11 +48,13 @@ namespace SabreTools /// 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 - /// True if blank items should be created for empty folders, false otherwise + /// 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 the file should not be written out, false otherwise (default) /// Logger object for console and file output - public DATFromDir(List inputs, Dat datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles, bool enableGzip, bool addblanks, string tempDir, Logger logger, bool nowrite = false) + public DATFromDir(List inputs, Dat datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles, + bool enableGzip, bool addBlanks, bool addDate, string tempDir, Logger logger, bool nowrite = false) { _inputs = inputs; _datdata = datdata; @@ -62,7 +65,8 @@ namespace SabreTools _enableGzip = enableGzip; _tempDir = tempDir; _logger = logger; - _addblanks = addblanks; + _addBlanks = addBlanks; + _addDate = addDate; _nowrite = nowrite; } @@ -167,7 +171,7 @@ namespace SabreTools } // Now find all folders that are empty, if we are supposed to - if (!_datdata.Romba && _addblanks) + if (!_datdata.Romba && _addBlanks) { // If there were no subitems, add a "blank" game to to the set (if not in Romba mode) if (!items) @@ -257,7 +261,7 @@ namespace SabreTools } // Now find all folders that are empty, if we are supposed to - if (!_datdata.Romba && _addblanks) + if (!_datdata.Romba && _addBlanks) { List keys = _datdata.Files.Keys.ToList(); foreach (string key in keys) @@ -465,7 +469,7 @@ namespace SabreTools private string ProcessFile(string item, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent) { _logger.Log(Path.GetFileName(item) + " treated like a file"); - Rom rom = FileTools.GetSingleFileInfo(item, _noMD5, _noSHA1); + Rom rom = FileTools.GetSingleFileInfo(item, noMD5: _noMD5, noSHA1: _noSHA1, date: _addDate); return ProcessFileHelper(item, rom, sw, basepath, parent, datdata, lastparent); } diff --git a/SabreTools.Helper/Objects/DATFromDirParallel.cs b/SabreTools.Helper/Objects/DATFromDirParallel.cs index 3ec1c4be..38aa6d37 100644 --- a/SabreTools.Helper/Objects/DATFromDirParallel.cs +++ b/SabreTools.Helper/Objects/DATFromDirParallel.cs @@ -24,7 +24,8 @@ namespace SabreTools private bool _bare; private bool _archivesAsFiles; private bool _enableGzip; - private bool _addblanks; + private bool _addBlanks; + private bool _addDate; private int _maxDegreeOfParallelism; // Other required variables @@ -46,12 +47,13 @@ namespace SabreTools /// 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 - /// True if blank items should be created for empty folders, false otherwise + /// 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) /// Integer representing the maximum amount of parallelization to be used /// Logger object for console and file output - public DATFromDirParallel(string basePath, Dat datdata, bool noMD5, bool noSHA1, bool bare, - bool archivesAsFiles, bool enableGzip, bool addblanks, string tempDir, int maxDegreeOfParallelism, Logger logger) + public DATFromDirParallel(string basePath, Dat datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles, + bool enableGzip, bool addBlanks, bool addDate, string tempDir, int maxDegreeOfParallelism, Logger logger) { _basePath = Path.GetFullPath(basePath); _datdata = datdata; @@ -62,7 +64,8 @@ namespace SabreTools _bare = bare; _archivesAsFiles = archivesAsFiles; _enableGzip = enableGzip; - _addblanks = addblanks; + _addBlanks = addBlanks; + _addDate = addDate; _tempDir = tempDir; _maxDegreeOfParallelism = maxDegreeOfParallelism; _logger = logger; @@ -105,7 +108,7 @@ namespace SabreTools }); // Now find all folders that are empty, if we are supposed to - if (!_datdata.Romba && _addblanks) + if (!_datdata.Romba && _addBlanks) { Parallel.ForEach(Directory.EnumerateDirectories(_basePath, "*", SearchOption.AllDirectories), new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism }, @@ -297,7 +300,7 @@ namespace SabreTools private void ProcessFile(string item, string basepath, string parent) { _logger.Log(Path.GetFileName(item) + " treated like a file"); - Rom rom = FileTools.GetSingleFileInfo(item, _noMD5, _noSHA1); + Rom rom = FileTools.GetSingleFileInfo(item, noMD5:_noMD5, noSHA1: _noSHA1, date: _addDate); ProcessFileHelper(item, rom, basepath, parent); } diff --git a/SabreTools.Helper/Objects/SimpleSort.cs b/SabreTools.Helper/Objects/SimpleSort.cs index eddd247e..382d0ec3 100644 --- a/SabreTools.Helper/Objects/SimpleSort.cs +++ b/SabreTools.Helper/Objects/SimpleSort.cs @@ -133,7 +133,7 @@ namespace SabreTools.Helper // Then, loop through and check each of the inputs _logger.User("Processing files:\n"); DATFromDir dfd = new DATFromDir(files, _datdata, false /* noMD5 */, false /* noSHA1 */, false /* bare */, - false /* archivesAsFiles */, true /* enableGzip */, false /* addblanks */, "" /* tempdir */, _logger, true /* nowrite */); + false /* archivesAsFiles */, true /* enableGzip */, false /* addBlanks */, false /* addDate */, "" /* tempdir */, _logger, true /* nowrite */); dfd.Start(); // Setup the fixdat diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index d2717aac..87e1a91a 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -230,6 +230,15 @@ Options: Set the type flag to "SuperDAT" for the output DAT as well as preserving the directory structure of the inputted folder, if applicable + -ab, --add-blank Output blank files for folders + If this flag is set, then blank entries will be created for each of the empty + directories in the source. This is useful for tools that require all folders + be accounted for in the output DAT. + + -ad, --add-date Output dates for each file parsed + If this flag is set, then the Date will be appended to each file information + in the output DAT. The output format is standardized as "yyyy/MM/dd HH:mm:ss". + -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 diff --git a/SabreTools.Helper/Tools/FileTools.cs b/SabreTools.Helper/Tools/FileTools.cs index b0ad2207..c3078542 100644 --- a/SabreTools.Helper/Tools/FileTools.cs +++ b/SabreTools.Helper/Tools/FileTools.cs @@ -632,11 +632,13 @@ namespace SabreTools.Helper /// Retrieve file information for a single file /// /// Filename to get information from - /// True if MD5 hashes should not be calculated, false otherwise - /// True if SHA-1 hashes should not be calcluated, false otherwise + /// True if MD5 hashes should not be calculated, false otherwise (default) + /// True if SHA-1 hashes should not be calcluated, false otherwise (default) + /// Set a >0 number for getting hash for part of the file, 0 otherwise (default) + /// True if the file Date should be included, false otherwise (default) /// Populated RomData object if success, empty one on error /// Add read-offset for hash info - public static Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0) + public static Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0, bool date = false) { // Add safeguard if file doesn't exist if (!File.Exists(input)) @@ -656,7 +658,7 @@ namespace SabreTools.Helper MD5 = string.Empty, SHA1 = string.Empty, }, - //Date = temp.LastWriteTime.ToString(), + Date = (date ? temp.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : ""), }; try diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 5ac4dd23..119ec416 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -101,7 +101,8 @@ namespace SabreTools /// 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 - /// True if blank items should be created for empty folders, false otherwise + /// 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 /// Integer representing the maximum amount of parallelization to be used private static void InitDatFromDir(List inputs, @@ -120,7 +121,8 @@ namespace SabreTools bool bare, bool archivesAsFiles, bool enableGzip, - bool addblanks, + bool addBlanks, + bool addDate, string tempDir, int maxDegreeOfParallelism) { @@ -144,7 +146,7 @@ namespace SabreTools // If the user has only set a single thread, use the original version if (maxDegreeOfParallelism == 1) { - DATFromDir dfd = new DATFromDir(inputs, basedat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addblanks, tempDir, _logger); + DATFromDir dfd = new DATFromDir(inputs, basedat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addBlanks, addDate, tempDir, _logger); bool success = dfd.Start(); // If we failed, show the help @@ -168,7 +170,7 @@ namespace SabreTools datdata.Files = new Dictionary>(); string basePath = Path.GetFullPath(path); - DATFromDirParallel dfd = new DATFromDirParallel(basePath, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addblanks, tempDir, maxDegreeOfParallelism, _logger); + DATFromDirParallel dfd = new DATFromDirParallel(basePath, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addBlanks, addDate, tempDir, maxDegreeOfParallelism, _logger); bool success = dfd.Start(); // If it was a success, write the DAT out diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 7d2f86c6..ffe138ce 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -77,7 +77,8 @@ namespace SabreTools // Set all default values bool help = false, add = false, - addblanks = false, + addBlanks = false, + addDate = false, archivesAsFiles = false, bare = false, clean = false, @@ -177,6 +178,14 @@ namespace SabreTools case "--add": add = true; break; + case "-ab": + case "--add-blank": + addBlanks = true; + break; + case "-ad": + case "--add-date": + addDate = true; + break; case "-b": case "--bare": bare = true; @@ -661,7 +670,7 @@ namespace SabreTools else if (datfromdir) { InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, outputFormat, - romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addblanks, tempdir, maxParallelism); + romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addBlanks, addDate, tempdir, maxParallelism); } // Split a DAT by extension