[ArchiveTools] Reorganize code to make more sense

This commit is contained in:
Matt Nadareski
2016-08-18 15:50:57 -07:00
parent 88edc5afa3
commit 3f3f5a4786

View File

@@ -187,26 +187,8 @@ namespace SabreTools.Helper
sza.WriteToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); sza.WriteToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
encounteredErrors = false; encounteredErrors = false;
} }
else
{
reader = ReaderFactory.Open(File.OpenRead(input));
logger.Log("Found archive of type: " + at);
if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External) ||
(at == ArchiveType.Rar && rar != ArchiveScanLevel.External))
{
// Create the temp directory
Directory.CreateDirectory(tempdir);
// Extract all files to the temp directory
reader.WriteAllToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
encounteredErrors = false;
}
else if (at == ArchiveType.GZip && gz != ArchiveScanLevel.External) else if (at == ArchiveType.GZip && gz != ArchiveScanLevel.External)
{ {
// Close the original archive handle
reader.Dispose();
// Create the temp directory // Create the temp directory
Directory.CreateDirectory(tempdir); Directory.CreateDirectory(tempdir);
@@ -222,6 +204,21 @@ namespace SabreTools.Helper
} }
encounteredErrors = false; encounteredErrors = false;
} }
else
{
reader = ReaderFactory.Open(File.OpenRead(input));
logger.Log("Found archive of type: " + at);
if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External) ||
(at == ArchiveType.Rar && rar != ArchiveScanLevel.External))
{
// Create the temp directory
Directory.CreateDirectory(tempdir);
// Extract all files to the temp directory
reader.WriteAllToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
encounteredErrors = false;
}
} }
} }
catch (EndOfStreamException) catch (EndOfStreamException)