-
Notifications
You must be signed in to change notification settings - Fork 35
Add ARJ, ARC, and ACE archive decompression support #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b3482f9
5d90944
e03db48
4f47643
fba41e2
9444f82
ac4537f
755b17e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,173 @@ | ||||||
| using SharpCompress.Readers; | ||||||
| using SharpCompress.Readers.Ace; | ||||||
| using System; | ||||||
| using System.Collections.Generic; | ||||||
| using System.IO; | ||||||
|
|
||||||
| namespace Microsoft.CST.RecursiveExtractor.Extractors | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// The ACE Archive extractor implementation | ||||||
| /// </summary> | ||||||
| public class AceExtractor : AsyncExtractorInterface | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// The constructor takes the Extractor context for recursion. | ||||||
| /// </summary> | ||||||
| /// <param name="context">The Extractor context.</param> | ||||||
| public AceExtractor(Extractor context) | ||||||
| { | ||||||
| Context = context; | ||||||
| } | ||||||
| private readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); | ||||||
|
|
||||||
| internal Extractor Context { get; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Extracts an ACE archive | ||||||
| /// </summary> | ||||||
| ///<inheritdoc /> | ||||||
| public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor, bool topLevel = true) | ||||||
| { | ||||||
| AceReader? aceReader = null; | ||||||
| try | ||||||
| { | ||||||
| aceReader = AceReader.Open(fileEntry.Content, new ReaderOptions() | ||||||
| { | ||||||
| LeaveStreamOpen = true | ||||||
| }); | ||||||
|
Comment on lines
+33
to
+38
|
||||||
| } | ||||||
| catch (Exception e) | ||||||
| { | ||||||
| Logger.Debug(Extractor.FAILED_PARSING_ERROR_MESSAGE_STRING, ArchiveFileType.ACE, fileEntry.FullPath, string.Empty, e.GetType()); | ||||||
| } | ||||||
|
|
||||||
| if (aceReader != null) | ||||||
| { | ||||||
| using (aceReader) | ||||||
| { | ||||||
| while (aceReader.MoveToNextEntry()) | ||||||
| { | ||||||
| var entry = aceReader.Entry; | ||||||
| if (entry.IsDirectory) | ||||||
| { | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| var name = entry.Key?.Replace('/', Path.DirectorySeparatorChar); | ||||||
| if (string.IsNullOrEmpty(name)) | ||||||
| { | ||||||
| Logger.Debug(Extractor.ENTRY_MISSING_NAME_ERROR_MESSAGE_STRING, ArchiveFileType.ACE, fileEntry.FullPath); | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| governor.CheckResourceGovernor(entry.Size); | ||||||
| using var entryStream = aceReader.OpenEntryStream() | ||||||
|
||||||
| using var entryStream = aceReader.OpenEntryStream() | |
| using (var entryStream = aceReader.OpenEntryStream()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
stream.Close()call: the stream is already disposed by theusing var stream = new FileStream(...). Removing the explicit close reduces noise and avoids confusion about ownership/lifetime.