mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[FileTools] Rename ArchiveTools to FileTools
This commit is contained in:
@@ -106,7 +106,7 @@
|
||||
<DependentUpon>Resources.fr-FR.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Skippers.cs" />
|
||||
<Compile Include="Tools\ArchiveTools.cs" />
|
||||
<Compile Include="Tools\FileTools.cs" />
|
||||
<Compile Include="Tools\CRC32.cs" />
|
||||
<Compile Include="Tools\DBTools.cs" />
|
||||
<Compile Include="Data\Enums.cs" />
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace SabreTools.Helper
|
||||
{
|
||||
public class ArchiveTools
|
||||
public class FileTools
|
||||
{
|
||||
#region Archive Writing
|
||||
|
||||
@@ -573,7 +573,7 @@ namespace SabreTools.Helper
|
||||
|
||||
#endregion
|
||||
|
||||
#region Archive Information Methods
|
||||
#region File Information Methods
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of RomData objects from the header values in an archive
|
||||
@@ -828,7 +828,7 @@ namespace SabreTools.Helper
|
||||
shouldExternalProcess = true;
|
||||
shouldInternalProcess = true;
|
||||
|
||||
ArchiveType? archiveType = ArchiveTools.GetCurrentArchiveType(input, logger);
|
||||
ArchiveType? archiveType = FileTools.GetCurrentArchiveType(input, logger);
|
||||
switch (archiveType)
|
||||
{
|
||||
case null:
|
||||
@@ -346,7 +346,7 @@ namespace SabreTools
|
||||
// Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
|
||||
if (_datdata.Romba)
|
||||
{
|
||||
Rom rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger);
|
||||
Rom rom = FileTools.GetTorrentGZFileInfo(item, _logger);
|
||||
|
||||
// If the rom is valid, write it out
|
||||
if (rom.Name != null)
|
||||
@@ -386,12 +386,12 @@ namespace SabreTools
|
||||
// If both deep hash skip flags are set, do a quickscan
|
||||
if (_noMD5 && _noSHA1)
|
||||
{
|
||||
ArchiveType? type = ArchiveTools.GetCurrentArchiveType(item, _logger);
|
||||
ArchiveType? type = FileTools.GetCurrentArchiveType(item, _logger);
|
||||
|
||||
// If we have an archive, scan it
|
||||
if (type != null)
|
||||
{
|
||||
List<Rom> extracted = ArchiveTools.GetArchiveFileInfo(item, _logger);
|
||||
List<Rom> extracted = FileTools.GetArchiveFileInfo(item, _logger);
|
||||
foreach (Rom rom in extracted)
|
||||
{
|
||||
lastparent = ProcessFileHelper(item, rom, sw, _basePath,
|
||||
@@ -409,7 +409,7 @@ namespace SabreTools
|
||||
// Otherwise, attempt to extract the files to the temporary directory
|
||||
else
|
||||
{
|
||||
bool encounteredErrors = ArchiveTools.ExtractArchive(item,
|
||||
bool encounteredErrors = FileTools.ExtractArchive(item,
|
||||
tempdir,
|
||||
(_archivesAsFiles ? ArchiveScanLevel.External : ArchiveScanLevel.Internal),
|
||||
(!_archivesAsFiles && _enableGzip ? ArchiveScanLevel.Internal : ArchiveScanLevel.External),
|
||||
|
||||
@@ -487,7 +487,7 @@ namespace SabreTools
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalScan, shouldInternalScan;
|
||||
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalScan, out shouldInternalScan);
|
||||
FileTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalScan, out shouldInternalScan);
|
||||
|
||||
// Hash and match the external files
|
||||
if (shouldExternalScan)
|
||||
@@ -540,11 +540,11 @@ namespace SabreTools
|
||||
{
|
||||
if (_tgz)
|
||||
{
|
||||
ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArchiveTools.WriteToManagedArchive(input, _outdir, found);
|
||||
FileTools.WriteToManagedArchive(input, _outdir, found);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,11 +607,11 @@ namespace SabreTools
|
||||
{
|
||||
if (_tgz)
|
||||
{
|
||||
ArchiveTools.WriteTorrentGZ(newinput, _outdir, _romba, _logger);
|
||||
FileTools.WriteTorrentGZ(newinput, _outdir, _romba, _logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArchiveTools.WriteToManagedArchive(newinput, _outdir, found);
|
||||
FileTools.WriteToManagedArchive(newinput, _outdir, found);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,11 +653,11 @@ namespace SabreTools
|
||||
_logger.Log("Matched name: " + newfound.Name);
|
||||
if (_tgz)
|
||||
{
|
||||
ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArchiveTools.WriteToManagedArchive(input, _outdir, newfound);
|
||||
FileTools.WriteToManagedArchive(input, _outdir, newfound);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -681,7 +681,7 @@ namespace SabreTools
|
||||
if (_quickScan)
|
||||
{
|
||||
_logger.Log("Beginning quick scan of contents from '" + input + "'");
|
||||
List<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
||||
List<Rom> internalRomData = FileTools.GetArchiveFileInfo(input, _logger);
|
||||
_logger.Log(internalRomData.Count + " entries found in '" + input + "'");
|
||||
|
||||
// If the list is populated, then the file was a filled archive
|
||||
@@ -711,7 +711,7 @@ namespace SabreTools
|
||||
{
|
||||
// Copy file to output directory
|
||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||
if (File.Exists(outfile))
|
||||
{
|
||||
string gamedir = Path.Combine(_outdir, found.Machine.Name);
|
||||
@@ -734,16 +734,16 @@ namespace SabreTools
|
||||
|
||||
if (Build.MonoEnvironment || _tgz)
|
||||
{
|
||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||
if (File.Exists(outfile))
|
||||
{
|
||||
if (_tgz)
|
||||
{
|
||||
ArchiveTools.WriteTorrentGZ(outfile, _outdir, _romba, _logger);
|
||||
FileTools.WriteTorrentGZ(outfile, _outdir, _romba, _logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArchiveTools.WriteToManagedArchive(outfile, _outdir, found);
|
||||
FileTools.WriteToManagedArchive(outfile, _outdir, found);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -756,7 +756,7 @@ namespace SabreTools
|
||||
else
|
||||
{
|
||||
string archiveFileName = Path.Combine(_outdir, found.Machine + ".zip");
|
||||
ArchiveTools.CopyFileBetweenManagedArchives(input, archiveFileName, rom.Name, found.Name, _logger);
|
||||
FileTools.CopyFileBetweenManagedArchives(input, archiveFileName, rom.Name, found.Name, _logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -766,7 +766,7 @@ namespace SabreTools
|
||||
else
|
||||
{
|
||||
// Now, if the file is a supported archive type, also run on all files within
|
||||
bool encounteredErrors = ArchiveTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
||||
bool encounteredErrors = FileTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
||||
|
||||
// Remove the current file if we are in recursion so it's not picked up in the next step
|
||||
if (recurse)
|
||||
@@ -832,13 +832,13 @@ namespace SabreTools
|
||||
List<Rom> roms = new List<Rom>();
|
||||
if (_quickScan)
|
||||
{
|
||||
roms = ArchiveTools.GetArchiveFileInfo(Path.GetFullPath(archive), _logger);
|
||||
roms = FileTools.GetArchiveFileInfo(Path.GetFullPath(archive), _logger);
|
||||
}
|
||||
// Otherwise, extract it and get info one by one
|
||||
else
|
||||
{
|
||||
string temparcdir = Path.Combine(_tempdir, Path.GetFileNameWithoutExtension(archive));
|
||||
ArchiveTools.ExtractArchive(Path.GetFullPath(archive), temparcdir, _logger);
|
||||
FileTools.ExtractArchive(Path.GetFullPath(archive), temparcdir, _logger);
|
||||
foreach (string tempfile in Directory.EnumerateFiles(temparcdir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
roms.Add(RomTools.GetSingleFileInfo(Path.GetFullPath(tempfile)));
|
||||
|
||||
@@ -272,20 +272,20 @@ namespace SabreTools
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalProcess, shouldInternalProcess;
|
||||
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalProcess, out shouldInternalProcess);
|
||||
FileTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalProcess, out shouldInternalProcess);
|
||||
|
||||
// Do an external scan of the file, if necessary
|
||||
if (shouldExternalProcess)
|
||||
{
|
||||
_logger.User("Processing file " + input);
|
||||
success &= ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
success &= FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
}
|
||||
|
||||
// Process the file as an archive, if necessary
|
||||
if (shouldInternalProcess)
|
||||
{
|
||||
// Now, if the file is a supported archive type, also run on all files within
|
||||
bool encounteredErrors = ArchiveTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
||||
bool encounteredErrors = FileTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
||||
|
||||
// If no errors were encountered, we loop through the temp directory
|
||||
if (!encounteredErrors)
|
||||
@@ -294,7 +294,7 @@ namespace SabreTools
|
||||
foreach (string file in Directory.EnumerateFiles(_tempdir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
_logger.User("Processing extracted file " + file);
|
||||
success &= ArchiveTools.WriteTorrentGZ(file, _outdir, _romba, _logger);
|
||||
success &= FileTools.WriteTorrentGZ(file, _outdir, _romba, _logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user