[SabreTools, DatFile, README.1ST] GZ files are archives

This commit is contained in:
Matt Nadareski
2017-10-31 16:44:47 -07:00
parent 9856426cce
commit 5750ba43c8
5 changed files with 9 additions and 36 deletions

View File

@@ -3468,7 +3468,6 @@ namespace SabreTools.Library.DatFiles
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param> /// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param>
/// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param> /// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param>
/// <param name="archivesAsFiles">True if archives should be treated as files, false otherwise</param> /// <param name="archivesAsFiles">True if archives should be treated as files, false otherwise</param>
/// <param name="enableGzip">True if GZIP archives should be treated as files, false otherwise</param>
/// <param name="skipFileType">Type of files that should be skipped</param> /// <param name="skipFileType">Type of files that should be skipped</param>
/// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param> /// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param>
/// <param name="addDate">True if dates should be archived for all files, false otherwise</param> /// <param name="addDate">True if dates should be archived for all files, false otherwise</param>
@@ -3477,9 +3476,8 @@ namespace SabreTools.Library.DatFiles
/// <param name="copyFiles">True if files should be copied to the temp directory before hashing, false otherwise</param> /// <param name="copyFiles">True if files should be copied to the temp directory before hashing, false otherwise</param>
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param> /// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
/// <param name="ignorechd">True if CHDs should be treated like regular files, false otherwise</param> /// <param name="ignorechd">True if CHDs should be treated like regular files, false otherwise</param>
public bool PopulateFromDir(string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, bool enableGzip, public bool PopulateFromDir(string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, SkipFileType skipFileType,
SkipFileType skipFileType, bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool ignorechd)
bool ignorechd)
{ {
// If the description is defined but not the name, set the name from the description // If the description is defined but not the name, set the name from the description
if (String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) if (String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description))
@@ -3509,7 +3507,7 @@ namespace SabreTools.Library.DatFiles
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.TopDirectoryOnly).ToList(); List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.TopDirectoryOnly).ToList();
Parallel.ForEach(files, Globals.ParallelOptions, item => Parallel.ForEach(files, Globals.ParallelOptions, item =>
{ {
CheckFileForHashes(item, basePath, omitFromScan, bare, archivesAsFiles, enableGzip, skipFileType, CheckFileForHashes(item, basePath, omitFromScan, bare, archivesAsFiles, skipFileType,
addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd);
}); });
@@ -3520,7 +3518,7 @@ namespace SabreTools.Library.DatFiles
List<string> subfiles = Directory.EnumerateFiles(item, "*", SearchOption.AllDirectories).ToList(); List<string> subfiles = Directory.EnumerateFiles(item, "*", SearchOption.AllDirectories).ToList();
Parallel.ForEach(subfiles, Globals.ParallelOptions, subitem => Parallel.ForEach(subfiles, Globals.ParallelOptions, subitem =>
{ {
CheckFileForHashes(subitem, basePath, omitFromScan, bare, archivesAsFiles, enableGzip, skipFileType, CheckFileForHashes(subitem, basePath, omitFromScan, bare, archivesAsFiles, skipFileType,
addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd);
}); });
} }
@@ -3577,7 +3575,7 @@ namespace SabreTools.Library.DatFiles
} }
else if (File.Exists(basePath)) else if (File.Exists(basePath))
{ {
CheckFileForHashes(basePath, Path.GetDirectoryName(Path.GetDirectoryName(basePath)), omitFromScan, bare, archivesAsFiles, enableGzip, CheckFileForHashes(basePath, Path.GetDirectoryName(Path.GetDirectoryName(basePath)), omitFromScan, bare, archivesAsFiles,
skipFileType, addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd); skipFileType, addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, ignorechd);
} }
@@ -3599,7 +3597,6 @@ namespace SabreTools.Library.DatFiles
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param> /// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param>
/// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param> /// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param>
/// <param name="archivesAsFiles">True if archives should be treated as files, false otherwise</param> /// <param name="archivesAsFiles">True if archives should be treated as files, false otherwise</param>
/// <param name="enableGzip">True if GZIP archives should be treated as files, false otherwise</param>
/// <param name="skipFileType">Type of files that should be skipped</param> /// <param name="skipFileType">Type of files that should be skipped</param>
/// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param> /// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param>
/// <param name="addDate">True if dates should be archived for all files, false otherwise</param> /// <param name="addDate">True if dates should be archived for all files, false otherwise</param>
@@ -3608,8 +3605,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param> /// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
/// <param name="ignorechd">True if CHDs should be treated like regular files, false otherwise</param> /// <param name="ignorechd">True if CHDs should be treated like regular files, false otherwise</param>
private void CheckFileForHashes(string item, string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, private void CheckFileForHashes(string item, string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles,
bool enableGzip, SkipFileType skipFileType, bool addBlanks, bool addDate, string tempDir, bool copyFiles, SkipFileType skipFileType, bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool ignorechd)
string headerToCheckAgainst, bool ignorechd)
{ {
// Define the temporary directory // Define the temporary directory
string tempSubDir = Path.GetFullPath(Path.Combine(tempDir, Path.GetRandomFileName())) + Path.DirectorySeparatorChar; string tempSubDir = Path.GetFullPath(Path.Combine(tempDir, Path.GetRandomFileName())) + Path.DirectorySeparatorChar;
@@ -3649,12 +3645,6 @@ namespace SabreTools.Library.DatFiles
// Create a list for all found items // Create a list for all found items
List<Rom> extracted = null; List<Rom> extracted = null;
// Temporarily set the archivesAsFiles if we have a GZip archive and we're not supposed to use it as one
if (archivesAsFiles && !enableGzip && newItem.EndsWith(".gz"))
{
archivesAsFiles = false;
}
// If we don't have archives as files, try to scan the file as an archive // If we don't have archives as files, try to scan the file as an archive
if (!archivesAsFiles) if (!archivesAsFiles)
{ {
@@ -4766,8 +4756,7 @@ namespace SabreTools.Library.DatFiles
{ {
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
PopulateFromDir(input, (quickScan ? Hash.SecureHashes : Hash.DeepHashes) /* omitFromScan */, true /* bare */, false /* archivesAsFiles */, PopulateFromDir(input, (quickScan ? Hash.SecureHashes : Hash.DeepHashes) /* omitFromScan */, true /* bare */, false /* archivesAsFiles */,
true /* enableGzip */, SkipFileType.None, false /* addBlanks */, false /* addDate */, "" /* tempDir */, false /* copyFiles */, SkipFileType.None, false /* addBlanks */, false /* addDate */, "" /* tempDir */, false /* copyFiles */, headerToCheckAgainst, ignorechd);
headerToCheckAgainst, ignorechd);
} }
// Setup the fixdat // Setup the fixdat

View File

@@ -262,10 +262,6 @@ Options:
-ox, -output-xml Output in Logiqx XML format (default) -ox, -output-xml Output in Logiqx XML format (default)
Add outputting the created DAT to Logiqx XML format Add outputting the created DAT to Logiqx XML format
-gzf, --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 -ro, --romba Read files from a Romba input
Allow for reading of GZipped files as if they were from a Romba Allow for reading of GZipped files as if they were from a Romba

View File

@@ -180,11 +180,6 @@ namespace SabreTools
"Output in Logiqx XML format [default]", "Output in Logiqx XML format [default]",
FeatureType.Flag, FeatureType.Flag,
null)); null));
datFromDir.AddFeature("gz-files", new Feature(
new List<string>() { "-gzf", "--gz-files" },
"Allow reading of GZIP files as archives",
FeatureType.Flag,
null));
datFromDir.AddFeature("romba", new Feature( datFromDir.AddFeature("romba", new Feature(
new List<string>() { "-ro", "--romba" }, new List<string>() { "-ro", "--romba" },
"Read files from a Romba input", "Read files from a Romba input",

View File

@@ -44,7 +44,6 @@ namespace SabreTools
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param> /// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param>
/// <param name="removeDateFromAutomaticName">True if the date should be omitted from the DAT, false otherwise</param> /// <param name="removeDateFromAutomaticName">True if the date should be omitted from the DAT, false otherwise</param>
/// <param name="parseArchivesAsFiles">True if archives should be treated as files, false otherwise</param> /// <param name="parseArchivesAsFiles">True if archives should be treated as files, false otherwise</param>
/// <param name="enableGzip">True if GZIP archives should be treated as files, false otherwise</param>
/// <param name="skipFileType">Type of files that should be skipped on scan</param> /// <param name="skipFileType">Type of files that should be skipped on scan</param>
/// <param name="addBlankFilesForEmptyFolder">True if blank items should be created for empty folders, false otherwise</param> /// <param name="addBlankFilesForEmptyFolder">True if blank items should be created for empty folders, false otherwise</param>
/// <param name="addFileDates">True if dates should be archived for all files, false otherwise</param> /// <param name="addFileDates">True if dates should be archived for all files, false otherwise</param>
@@ -77,7 +76,6 @@ namespace SabreTools
Hash omitFromScan, Hash omitFromScan,
bool removeDateFromAutomaticName, bool removeDateFromAutomaticName,
bool parseArchivesAsFiles, bool parseArchivesAsFiles,
bool enableGzip,
SkipFileType skipFileType, SkipFileType skipFileType,
bool addBlankFilesForEmptyFolder, bool addBlankFilesForEmptyFolder,
bool addFileDates, bool addFileDates,
@@ -138,7 +136,7 @@ namespace SabreTools
DatFile datdata = new DatFile(basedat); DatFile datdata = new DatFile(basedat);
string basePath = Path.GetFullPath(path); string basePath = Path.GetFullPath(path);
bool success = datdata.PopulateFromDir(basePath, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles, enableGzip, bool success = datdata.PopulateFromDir(basePath, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles,
skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, copyFiles, headerToCheckAgainst, ignorechd); skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, copyFiles, headerToCheckAgainst, ignorechd);
// If it was a success, write the DAT out // If it was a success, write the DAT out

View File

@@ -96,7 +96,6 @@ namespace SabreTools
datPrefix = false, datPrefix = false,
delete = false, delete = false,
descAsName = false, descAsName = false,
enableGzip = false,
excludeOf = false, excludeOf = false,
hashOnly = false, hashOnly = false,
ignorechd = false, ignorechd = false,
@@ -385,10 +384,6 @@ namespace SabreTools
case "--game-prefix": case "--game-prefix":
datPrefix = true; datPrefix = true;
break; break;
case "-gzf":
case "--gz-files":
enableGzip = true;
break;
case "-ho": case "-ho":
case "--hash-only": case "--hash-only":
hashOnly = true; hashOnly = true;
@@ -1260,7 +1255,7 @@ namespace SabreTools
{ {
InitDatFromDir(inputs, filename, name, description, category, version, author, email, homepage, url, comment, InitDatFromDir(inputs, filename, name, description, category, version, author, email, homepage, url, comment,
forcepack, excludeOf, sceneDateStrip, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles, forcepack, excludeOf, sceneDateStrip, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles,
enableGzip, skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, header, ignorechd); skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, header, ignorechd);
} }
// If we're in header extract and remove mode // If we're in header extract and remove mode