diff --git a/RombaSharp/RombaSharp.Inits.cs b/RombaSharp/RombaSharp.Inits.cs index 023138cb..9b977308 100644 --- a/RombaSharp/RombaSharp.Inits.cs +++ b/RombaSharp/RombaSharp.Inits.cs @@ -178,7 +178,7 @@ namespace RombaSharp ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers((onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1)); need.RebuildGeneric(onlyDirs, _depots.Keys.ToList()[0], false /*quickScan*/, false /*date*/, false /*delete*/, false /*inverse*/, OutputFormat.TorrentGzip, true /*romba*/, asl, false /*updateDat*/, - null /*headerToCheckAgainst*/, true /* ignorechd */); + null /*headerToCheckAgainst*/, true /* chdsAsFiles */); } /// @@ -254,7 +254,7 @@ namespace RombaSharp // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually datdata.PopulateFromDir(input, Hash.DeepHashes /* omitFromScan */, true /* bare */, false /* archivesAsFiles */, SkipFileType.None, false /* addBlanks */, false /* addDate */, _tmpdir /* tempDir */, false /* copyFiles */, - null /* headerToCheckAgainst */, true /* ignorechd */); + null /* headerToCheckAgainst */, true /* chdsAsFiles */); datdata.WriteToFile(""); } } diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index bbfb30f6..e151e4c9 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -3475,9 +3475,9 @@ namespace SabreTools.Library.DatFiles /// Output directory to /// True if files should be copied to the temp directory before hashing, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise public bool PopulateFromDir(string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, SkipFileType skipFileType, - bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool ignorechd) + bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles) { // If the description is defined but not the name, set the name from the description if (String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) @@ -3508,7 +3508,7 @@ namespace SabreTools.Library.DatFiles Parallel.ForEach(files, Globals.ParallelOptions, item => { CheckFileForHashes(item, basePath, omitFromScan, bare, archivesAsFiles, skipFileType, - addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); + addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles); }); // Find all top-level subfolders @@ -3519,7 +3519,7 @@ namespace SabreTools.Library.DatFiles Parallel.ForEach(subfiles, Globals.ParallelOptions, subitem => { CheckFileForHashes(subitem, basePath, omitFromScan, bare, archivesAsFiles, skipFileType, - addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); + addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles); }); } @@ -3576,7 +3576,7 @@ namespace SabreTools.Library.DatFiles else if (File.Exists(basePath)) { CheckFileForHashes(basePath, Path.GetDirectoryName(Path.GetDirectoryName(basePath)), omitFromScan, bare, archivesAsFiles, - skipFileType, addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); + skipFileType, addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles); } // Now that we're done, delete the temp folder (if it's not the default) @@ -3603,9 +3603,9 @@ namespace SabreTools.Library.DatFiles /// 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 /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private void CheckFileForHashes(string item, string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, - SkipFileType skipFileType, bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool ignorechd) + SkipFileType skipFileType, bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles) { // Define the temporary directory string tempSubDir = Path.GetFullPath(Path.Combine(tempDir, Path.GetRandomFileName())) + Path.DirectorySeparatorChar; @@ -3670,7 +3670,7 @@ namespace SabreTools.Library.DatFiles // If the extracted list is null, just scan the item itself if (extracted == null || archivesAsFiles) { - ProcessFile(newItem, "", newBasePath, omitFromScan, addDate, headerToCheckAgainst, ignorechd); + ProcessFile(newItem, "", newBasePath, omitFromScan, addDate, headerToCheckAgainst, chdsAsFiles); } // Otherwise, add all of the found items else @@ -3718,12 +3718,12 @@ namespace SabreTools.Library.DatFiles /// Hash flag saying what hashes should not be calculated /// True if dates should be archived for all files, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private void ProcessFile(string item, string parent, string basePath, Hash omitFromScan, - bool addDate, string headerToCheckAgainst, bool ignorechd) + bool addDate, string headerToCheckAgainst, bool chdsAsFiles) { Globals.Logger.Verbose("'{0}' treated like a file", Path.GetFileName(item)); - DatItem datItem = FileTools.GetFileInfo(item, omitFromScan: omitFromScan, date: addDate, header: headerToCheckAgainst, ignorechd: ignorechd); + DatItem datItem = FileTools.GetFileInfo(item, omitFromScan: omitFromScan, date: addDate, header: headerToCheckAgainst, chdsAsFiles: chdsAsFiles); ProcessFileHelper(item, datItem, basePath, parent); } @@ -4048,11 +4048,11 @@ namespace SabreTools.Library.DatFiles /// ArchiveScanLevel representing the archive handling levels /// True if the updated DAT should be output, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise /// True if rebuilding was a success, false otherwise public bool RebuildGeneric(List inputs, string outDir, bool quickScan, bool date, bool delete, bool inverse, OutputFormat outputFormat, bool romba, ArchiveScanLevel archiveScanLevel, bool updateDat, - string headerToCheckAgainst, bool ignorechd) + string headerToCheckAgainst, bool chdsAsFiles) { #region Perform setup @@ -4132,7 +4132,7 @@ namespace SabreTools.Library.DatFiles { Globals.Logger.User("Checking file: {0}", input); RebuildGenericHelper(input, outDir, quickScan, date, delete, inverse, - outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst, ignorechd); + outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst, chdsAsFiles); } // If the input is a directory @@ -4143,7 +4143,7 @@ namespace SabreTools.Library.DatFiles { Globals.Logger.User("Checking file: {0}", file); RebuildGenericHelper(file, outDir, quickScan, date, delete, inverse, - outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst, ignorechd); + outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst, chdsAsFiles); } } } @@ -4179,10 +4179,10 @@ namespace SabreTools.Library.DatFiles /// ArchiveScanLevel representing the archive handling levels /// True if the updated DAT should be output, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private void RebuildGenericHelper(string file, string outDir, bool quickScan, bool date, bool delete, bool inverse, OutputFormat outputFormat, bool romba, ArchiveScanLevel archiveScanLevel, bool updateDat, - string headerToCheckAgainst, bool ignorechd) + string headerToCheckAgainst, bool chdsAsFiles) { // If we somehow have a null filename, return if (file == null) @@ -4202,7 +4202,7 @@ namespace SabreTools.Library.DatFiles { // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually DatItem fileinfo = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), - header: headerToCheckAgainst, ignorechd: ignorechd); + header: headerToCheckAgainst, chdsAsFiles: chdsAsFiles); usedExternally = RebuildIndividualFile(fileinfo, file, outDir, date, inverse, outputFormat, romba, updateDat, null /* isZip */, headerToCheckAgainst); } @@ -4233,7 +4233,7 @@ namespace SabreTools.Library.DatFiles if (entries == null && File.Exists(file)) { // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually - DatItem fileinfo = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), ignorechd: ignorechd); + DatItem fileinfo = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), chdsAsFiles: chdsAsFiles); usedExternally = RebuildIndividualFile(fileinfo, file, outDir, date, inverse, outputFormat, romba, updateDat, null /* isZip */, headerToCheckAgainst); } @@ -4743,9 +4743,9 @@ namespace SabreTools.Library.DatFiles /// True if only hashes should be checked, false for full file information /// True to enable external scanning of archives, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise /// True if verification was a success, false otherwise - public bool VerifyGeneric(List inputs, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool ignorechd) + public bool VerifyGeneric(List inputs, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool chdsAsFiles) { // TODO: We want the cross section of what's the folder and what's in the DAT. Right now, it just has what's in the DAT that's not in the folder bool success = true; @@ -4756,7 +4756,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 */, "" /* tempDir */, false /* copyFiles */, headerToCheckAgainst, ignorechd); + SkipFileType.None, false /* addBlanks */, false /* addDate */, "" /* tempDir */, false /* copyFiles */, headerToCheckAgainst, chdsAsFiles); } // Setup the fixdat diff --git a/SabreTools.Library/Tools/FileTools.cs b/SabreTools.Library/Tools/FileTools.cs index 236cead8..e7e37437 100644 --- a/SabreTools.Library/Tools/FileTools.cs +++ b/SabreTools.Library/Tools/FileTools.cs @@ -212,10 +212,10 @@ namespace SabreTools.Library.Tools /// 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 string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise /// Populated DatItem object if success, empty one on error public static DatItem GetFileInfo(string input, Hash omitFromScan = 0x0, - long offset = 0, bool date = false, string header = null, bool ignorechd = true) + long offset = 0, bool date = false, string header = null, bool chdsAsFiles = true) { // Add safeguard if file doesn't exist if (!File.Exists(input)) @@ -238,7 +238,7 @@ namespace SabreTools.Library.Tools // Transform the stream and get the information from it rule.TransformStream(inputStream, outputStream, keepReadOpen: false, keepWriteOpen: true); - datItem = GetStreamInfo(outputStream, outputStream.Length, omitFromScan: omitFromScan, keepReadOpen: false, ignorechd: ignorechd); + datItem = GetStreamInfo(outputStream, outputStream.Length, omitFromScan: omitFromScan, keepReadOpen: false, chdsAsFiles: chdsAsFiles); // Dispose of the streams outputStream.Dispose(); @@ -248,13 +248,13 @@ namespace SabreTools.Library.Tools else { long length = new FileInfo(input).Length; - datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, ignorechd: ignorechd); + datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, chdsAsFiles: chdsAsFiles); } } else { long length = new FileInfo(input).Length; - datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, ignorechd: ignorechd); + datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, chdsAsFiles: chdsAsFiles); } // Add unique data from the file @@ -439,7 +439,7 @@ namespace SabreTools.Library.Tools } // Now add the information to the database if it's not already there - Rom rom = (Rom)GetFileInfo(newfile, ignorechd: true); + Rom rom = (Rom)GetFileInfo(newfile, chdsAsFiles: true); DatabaseTools.AddHeaderToDatabase(hstr, rom.SHA1, rule.SourceFile); return true; @@ -538,7 +538,7 @@ namespace SabreTools.Library.Tools } // First, get the SHA-1 hash of the file - Rom rom = (Rom)GetFileInfo(file, ignorechd: true); + Rom rom = (Rom)GetFileInfo(file, chdsAsFiles: true); // Retrieve a list of all related headers from the database List headers = DatabaseTools.RetrieveHeadersFromDatabase(rom.SHA1); @@ -762,13 +762,13 @@ namespace SabreTools.Library.Tools /// Hash flag saying what hashes should not be calculated (defaults to none) /// Set a >0 number for getting hash for part of the file, 0 otherwise (default) /// True if the underlying read stream should be kept open, false otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise /// Populated DatItem object if success, empty one on error public static DatItem GetStreamInfo(Stream input, long size, Hash omitFromScan = 0x0, - long offset = 0, bool keepReadOpen = false, bool ignorechd = true) + long offset = 0, bool keepReadOpen = false, bool chdsAsFiles = true) { // We first check to see if it's a CHD - if (ignorechd == false && IsValidCHD(input)) + if (chdsAsFiles == false && IsValidCHD(input)) { // Seek to the starting position, if one is set try diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs index a6ea7d10..27c84c5e 100644 --- a/SabreTools/SabreTools.Inits.cs +++ b/SabreTools/SabreTools.Inits.cs @@ -43,7 +43,7 @@ namespace SabreTools /// True to enable SuperDAT-style reading, false otherwise /// Hash flag saying what hashes should not be calculated /// True if the date should be omitted from the DAT, false otherwise - /// True if archives should be treated as files, false otherwise + /// True if archives should be treated as files, false otherwise /// Type of files that should be skipped on scan /// True if blank items should be created for empty folders, false otherwise /// True if dates should be archived for all files, false otherwise @@ -52,7 +52,7 @@ namespace SabreTools /// Name of the directory to output the DAT to (blank is the current directory) /// True if files should be copied to the temp directory before hashing, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private static void InitDatFromDir(List inputs, /* Normal DAT header info */ string filename, @@ -75,7 +75,7 @@ namespace SabreTools bool superdat, Hash omitFromScan, bool removeDateFromAutomaticName, - bool parseArchivesAsFiles, + bool archivesAsFiles, SkipFileType skipFileType, bool addBlankFilesForEmptyFolder, bool addFileDates, @@ -85,7 +85,7 @@ namespace SabreTools string outDir, bool copyFiles, string headerToCheckAgainst, - bool ignorechd) + bool chdsAsFiles) { ForcePacking fp = ForcePacking.None; switch (forcepack?.ToLowerInvariant()) @@ -136,8 +136,8 @@ namespace SabreTools DatFile datdata = new DatFile(basedat); string basePath = Path.GetFullPath(path); - bool success = datdata.PopulateFromDir(basePath, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles, - skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, copyFiles, headerToCheckAgainst, ignorechd); + bool success = datdata.PopulateFromDir(basePath, omitFromScan, removeDateFromAutomaticName, archivesAsFiles, + skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles); // If it was a success, write the DAT out if (success) @@ -331,10 +331,10 @@ namespace SabreTools /// True if the updated DAT should be output, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise /// Type of the split that should be performed (split, merged, fully merged) - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private static void InitSort(List datfiles, List inputs, string outDir, bool quickScan, bool date, bool delete, bool inverse, OutputFormat outputFormat, bool romba, int sevenzip, int gz, int rar, int zip, bool updateDat, string headerToCheckAgainst, - SplitType splitType, bool ignorechd) + SplitType splitType, bool chdsAsFiles) { // Get the archive scanning level ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(sevenzip, gz, rar, zip); @@ -354,7 +354,7 @@ namespace SabreTools watch.Stop(); datdata.RebuildGeneric(inputs, outDir, quickScan, date, delete, inverse, outputFormat, romba, asl, - updateDat, headerToCheckAgainst, ignorechd); + updateDat, headerToCheckAgainst, chdsAsFiles); } /// @@ -743,9 +743,9 @@ namespace SabreTools /// True to enable external scanning of archives, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise /// Type of the split that should be performed (split, merged, fully merged) - /// True if CHDs should be treated like regular files, false otherwise + /// True if CHDs should be treated like regular files, false otherwise private static void InitVerify(List datfiles, List inputs, bool hashOnly, bool quickScan, - string headerToCheckAgainst, SplitType splitType, bool ignorechd) + string headerToCheckAgainst, SplitType splitType, bool chdsAsFiles) { // Get the archive scanning level ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1); @@ -764,7 +764,7 @@ namespace SabreTools watch.Stop(); - datdata.VerifyGeneric(inputs, hashOnly, quickScan, headerToCheckAgainst, ignorechd); + datdata.VerifyGeneric(inputs, hashOnly, quickScan, headerToCheckAgainst, chdsAsFiles); } /// diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index d1b122dc..e852a407 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -90,7 +90,9 @@ namespace SabreTools // User flags bool addBlankFilesForEmptyFolder = false, addFileDates = false, + archivesAsFiles = false, basedat = false, + chdsAsFiles = false, cleanGameNames = false, copyFiles = false, datPrefix = false, @@ -98,12 +100,10 @@ namespace SabreTools descAsName = false, excludeOf = false, hashOnly = false, - ignorechd = false, inplace = true, inverse = false, merge = false, oneGameOneRegion = false, - parseArchivesAsFiles = false, quickScan = false, quotes = false, remext = false, @@ -374,7 +374,7 @@ namespace SabreTools break; case "-f": case "--files": - parseArchivesAsFiles = true; + archivesAsFiles = true; break; case "-gdd": case "--game-dedup": @@ -394,7 +394,7 @@ namespace SabreTools break; case "-ic": case "--ignore-chd": - ignorechd = true; + chdsAsFiles = true; break; case "-in": case "--inverse": @@ -1254,8 +1254,8 @@ namespace SabreTools if (datFromDir) { InitDatFromDir(inputs, filename, name, description, category, version, author, email, homepage, url, comment, - forcepack, excludeOf, sceneDateStrip, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles, - skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, header, ignorechd); + forcepack, excludeOf, sceneDateStrip, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, archivesAsFiles, + skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, header, chdsAsFiles); } // If we're in header extract and remove mode @@ -1274,7 +1274,7 @@ namespace SabreTools else if (sort) { InitSort(datfiles, inputs, outDir, quickScan, addFileDates, delete, inverse, - outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, splitType, ignorechd); + outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, splitType, chdsAsFiles); } // If we're using the sorter from depot @@ -1326,7 +1326,7 @@ namespace SabreTools // If we're using the verifier else if (verify) { - InitVerify(datfiles, inputs, hashOnly, quickScan, header, splitType, ignorechd); + InitVerify(datfiles, inputs, hashOnly, quickScan, header, splitType, chdsAsFiles); } // If we're using the depot verifier