Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RecursiveExtractor/Extractors/AceExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public AceExtractor(Extractor context)
///<inheritdoc />
public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
AceReader? aceReader = null;
IReader? aceReader = null;
try
{
fileEntry.Content.Position = 0;
aceReader = AceReader.Open(fileEntry.Content, new ReaderOptions()
aceReader = AceReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -100,11 +100,11 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
///<inheritdoc />
public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
AceReader? aceReader = null;
IReader? aceReader = null;
try
{
fileEntry.Content.Position = 0;
aceReader = AceReader.Open(fileEntry.Content, new ReaderOptions()
aceReader = AceReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down
8 changes: 4 additions & 4 deletions RecursiveExtractor/Extractors/ArcExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public ArcExtractor(Extractor context)
///<inheritdoc />
public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
ArcReader? arcReader = null;
IReader? arcReader = null;
try
{
fileEntry.Content.Position = 0;
arcReader = ArcReader.Open(fileEntry.Content, new ReaderOptions()
arcReader = ArcReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -103,11 +103,11 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
///<inheritdoc />
public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
ArcReader? arcReader = null;
IReader? arcReader = null;
try
{
fileEntry.Content.Position = 0;
arcReader = ArcReader.Open(fileEntry.Content, new ReaderOptions()
arcReader = ArcReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down
8 changes: 4 additions & 4 deletions RecursiveExtractor/Extractors/ArjExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public ArjExtractor(Extractor context)
///<inheritdoc />
public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
ArjReader? arjReader = null;
IReader? arjReader = null;
try
{
fileEntry.Content.Position = 0;
arjReader = ArjReader.Open(fileEntry.Content, new ReaderOptions()
arjReader = ArjReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -100,11 +100,11 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
///<inheritdoc />
public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
ArjReader? arjReader = null;
IReader? arjReader = null;
try
{
fileEntry.Content.Position = 0;
arjReader = ArjReader.Open(fileEntry.Content, new ReaderOptions()
arjReader = ArjReader.OpenReader(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down
6 changes: 3 additions & 3 deletions RecursiveExtractor/Extractors/BZip2Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
var failed = false;
try
{
using var bzipStream = new BZip2Stream(fileEntry.Content, CompressionMode.Decompress, false);
using var bzipStream = BZip2Stream.Create(fileEntry.Content, CompressionMode.Decompress, false, leaveOpen: false);
await bzipStream.CopyToAsync(fs);
}
catch (Exception e)
Expand Down Expand Up @@ -99,7 +99,7 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti

try
{
using var bzipStream = new BZip2Stream(fileEntry.Content, CompressionMode.Decompress, false);
using var bzipStream = BZip2Stream.Create(fileEntry.Content, CompressionMode.Decompress, false, leaveOpen: false);
bzipStream.CopyTo(fs);
}
catch (Exception e)
Expand Down Expand Up @@ -139,4 +139,4 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
}
}
}
}
}
6 changes: 3 additions & 3 deletions RecursiveExtractor/Extractors/RarExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public RarExtractor(Extractor context)

try
{
rarArchive = RarArchive.Open(fileEntry.Content);
rarArchive = (RarArchive)RarArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { LeaveStreamOpen = true });
// Test for invalid archives. This will throw invalidformatexception
var t = rarArchive.IsSolid;
if (rarArchive.Entries.Any(x => x.IsEncrypted))
Expand Down Expand Up @@ -66,7 +66,7 @@ public RarExtractor(Extractor context)
try
{
fileEntry.Content.Position = 0;
rarArchive = RarArchive.Open(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { Password = password, LookForHeader = true });
rarArchive = (RarArchive)RarArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { Password = password, LookForHeader = true, LeaveStreamOpen = true });
var byt = new byte[1];
var encryptedEntry = rarArchive.Entries.FirstOrDefault(x => x is { IsEncrypted: true, Size: > 0 });
// Justification for !: Because we use FirstOrDefault encryptedEntry may be null, but we have a catch below for it
Expand Down Expand Up @@ -197,4 +197,4 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
}
}
}
}
}
6 changes: 3 additions & 3 deletions RecursiveExtractor/Extractors/SevenZipExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
var needsPassword = false;
try
{
sevenZipArchive = SevenZipArchive.Open(fileEntry.Content);
sevenZipArchive = (SevenZipArchive)SevenZipArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { LeaveStreamOpen = true });
if (sevenZipArchive.Entries.Where(x => !x.IsDirectory).Any(x => x.IsEncrypted))
{
needsPassword = true;
Expand Down Expand Up @@ -114,7 +114,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
try
{
fileEntry.Content.Position = 0;
sevenZipArchive = SevenZipArchive.Open(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { Password = password });
sevenZipArchive = (SevenZipArchive)SevenZipArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions() { Password = password, LeaveStreamOpen = true });
// When filenames are encrypted we can't access the size of individual files
// But if we can accesss the total uncompressed size we have the right password
try
Expand Down Expand Up @@ -197,4 +197,4 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
}
}
}
}
}
6 changes: 3 additions & 3 deletions RecursiveExtractor/Extractors/TarExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TarExtractor(Extractor context)
///<inheritdoc />
public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
using TarArchive archive = TarArchive.Open(fileEntry.Content, new SharpCompress.Readers.ReaderOptions()
using TarArchive archive = (TarArchive)TarArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -103,7 +103,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
///<inheritdoc />
public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true)
{
using TarArchive archive = TarArchive.Open(fileEntry.Content, new SharpCompress.Readers.ReaderOptions()
using TarArchive archive = (TarArchive)TarArchive.OpenArchive(fileEntry.Content, new SharpCompress.Readers.ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -224,4 +224,4 @@ internal TarEntryCollectionEnumerator(ICollection<TarArchiveEntry> entries, stri
}
}
}
}
}
14 changes: 7 additions & 7 deletions RecursiveExtractor/Extractors/ZipExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ZipExtractor(Extractor context)
{
// Create a new archive instance with the password to test it
fileEntry.Content.Position = 0;
using var testArchive = ZipArchive.Open(fileEntry.Content, new ReaderOptions()
using var testArchive = (ZipArchive)ZipArchive.OpenArchive(fileEntry.Content, new ReaderOptions()
{
Password = password,
LeaveStreamOpen = true
Expand Down Expand Up @@ -73,7 +73,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
try
{
fileEntry.Content.Position = 0;
zipArchive = ZipArchive.Open(fileEntry.Content, new ReaderOptions()
zipArchive = (ZipArchive)ZipArchive.OpenArchive(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -104,7 +104,7 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
// Recreate archive with password
zipArchive.Dispose();
fileEntry.Content.Position = 0;
zipArchive = ZipArchive.Open(fileEntry.Content, new ReaderOptions()
zipArchive = (ZipArchive)ZipArchive.OpenArchive(fileEntry.Content, new ReaderOptions()
{
Password = foundPassword,
LeaveStreamOpen = true
Expand Down Expand Up @@ -199,7 +199,7 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
try
{
fileEntry.Content.Position = 0;
zipArchive = ZipArchive.Open(fileEntry.Content, new ReaderOptions()
zipArchive = (ZipArchive)ZipArchive.OpenArchive(fileEntry.Content, new ReaderOptions()
{
LeaveStreamOpen = true
});
Expand Down Expand Up @@ -230,7 +230,7 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
// Recreate archive with password
zipArchive.Dispose();
fileEntry.Content.Position = 0;
zipArchive = ZipArchive.Open(fileEntry.Content, new ReaderOptions()
zipArchive = (ZipArchive)ZipArchive.OpenArchive(fileEntry.Content, new ReaderOptions()
{
Password = foundPassword,
LeaveStreamOpen = true
Expand Down Expand Up @@ -329,7 +329,7 @@ private async IAsyncEnumerable<FileEntry> YieldNonIndexedEntriesAsync(
IReader? forwardReader = null;
try
{
forwardReader = ReaderFactory.Open(parentEntry.Content, new ReaderOptions { LeaveStreamOpen = true });
forwardReader = ReaderFactory.OpenReader(parentEntry.Content, new ReaderOptions { LeaveStreamOpen = true });
}
catch (Exception ex)
{
Expand Down Expand Up @@ -413,7 +413,7 @@ private IEnumerable<FileEntry> YieldNonIndexedEntries(
IReader? forwardReader = null;
try
{
forwardReader = ReaderFactory.Open(parentEntry.Content, new ReaderOptions { LeaveStreamOpen = true });
forwardReader = ReaderFactory.OpenReader(parentEntry.Content, new ReaderOptions { LeaveStreamOpen = true });
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion RecursiveExtractor/RecursiveExtractor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="NLog" Version="6.0.3" />
<PackageReference Include="SharpCompress" Version="0.44.5" />
<PackageReference Include="SharpCompress" Version="0.47.4" />
<PackageReference Include="System.Linq.AsyncEnumerable" Version="10.0.0" />
</ItemGroup>

Expand Down
Loading