mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[TGZTest] Set up archive handling; fix directory inputs
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using SabreTools.Helper;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace SabreTools
|
||||
{
|
||||
@@ -19,8 +20,6 @@ namespace SabreTools
|
||||
private ArchiveScanLevel _zip;
|
||||
private Logger _logger;
|
||||
|
||||
// We still need access permissions for each of the archive files as well, kind of like DATFromDir
|
||||
|
||||
/// <summary>
|
||||
/// Create a new TGZTest object
|
||||
/// </summary>
|
||||
@@ -229,7 +228,7 @@ namespace SabreTools
|
||||
{
|
||||
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
newinputs.Add(Path.GetFullPath(input));
|
||||
newinputs.Add(Path.GetFullPath(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,10 +247,46 @@ namespace SabreTools
|
||||
{
|
||||
_logger.User("Processing file " + input);
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalProcess = true;
|
||||
bool shouldInternalProcess = true;
|
||||
|
||||
ArchiveType? archiveType = ArchiveTools.GetCurrentArchiveType(input, _logger);
|
||||
switch (archiveType)
|
||||
{
|
||||
case null:
|
||||
shouldExternalProcess = true;
|
||||
shouldInternalProcess = false;
|
||||
break;
|
||||
case ArchiveType.GZip:
|
||||
shouldExternalProcess = (_gz != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_gz != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Rar:
|
||||
shouldExternalProcess = (_rar != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_rar != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.SevenZip:
|
||||
shouldExternalProcess = (_7z != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_7z != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Zip:
|
||||
shouldExternalProcess = (_zip != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_zip != ArchiveScanLevel.External);
|
||||
break;
|
||||
}
|
||||
|
||||
// Do an external scan of the file, if necessary
|
||||
if (shouldExternalProcess)
|
||||
{
|
||||
ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||
}
|
||||
|
||||
// Process the file as an archive, if necessary
|
||||
if (shouldInternalProcess)
|
||||
{
|
||||
// DO THINGS
|
||||
}
|
||||
|
||||
// Delete the soruce file if we're supposed to
|
||||
if (_delete)
|
||||
@@ -268,6 +303,19 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
|
||||
// Now one final delete of the temp directory
|
||||
while (Directory.Exists(_tempdir))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(_tempdir, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,10 @@
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpCompress, Version=0.12.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpCompress.0.12.4\lib\net45\SharpCompress.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -68,6 +72,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Helper\SabreTools.Helper.csproj">
|
||||
|
||||
4
TGZTest/packages.config
Normal file
4
TGZTest/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SharpCompress" version="0.12.4" targetFramework="net452" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user