-
Notifications
You must be signed in to change notification settings - Fork 14
Allow opening archive files. #692
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?
Conversation
f20b3d9 to
ef28701
Compare
|
This is somewhat an experimental implementation. When opening a file in the UI, change "filter" to "All files" and then select a zip/tar/tgz/tar.gz formatted file. |
- Add a dive aware archive extractor. - Extract content to temp file if we opened an archive. - Update path lookup logic.
| archive_read_free(archive_reader); | ||
| } | ||
|
|
||
| using UniqueArchiveReadPtr = std::unique_ptr<struct archive, decltype(&ArchiveReadCloseAndFree)>; |
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.
👍 Good use of unique_ptr to create an RAII type
| while (true) | ||
| { | ||
| struct archive_entry* entry = nullptr; | ||
| if (auto res = archive_read_next_header(reader.get(), &entry); res != ARCHIVE_OK) |
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.
nit: since res isn't used outside the if, can be omitted
| if (auto res = archive_read_next_header(reader.get(), &entry); res != ARCHIVE_OK) | |
| if (archive_read_next_header(reader.get(), &entry) != ARCHIVE_OK) |
|
|
||
| auto dst_file_path = dst / entry_path.filename(); | ||
| std::ofstream dst_file(dst_file_path, std::ios::binary | std::ios::out); | ||
| if (auto res = WriteArchiveEntry(dst_file, reader.get()); res != ARCHIVE_OK) |
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.
nit: since res isn't used outside the if, can be omitted
| if (auto res = WriteArchiveEntry(dst_file, reader.get()); res != ARCHIVE_OK) | |
| if (WriteArchiveEntry(dst_file, reader.get()) != ARCHIVE_OK) |
| if (auto res = archive_read_open_filename(reader.get(), m_path.string().c_str(), kBlockSize); | ||
| res != ARCHIVE_OK) |
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.
nit: since res isn't used outside the if, can be omitted
| if (auto res = archive_read_open_filename(reader.get(), m_path.string().c_str(), kBlockSize); | |
| res != ARCHIVE_OK) | |
| if (archive_read_open_filename(reader.get(), m_path.string().c_str(), kBlockSize) != ARCHIVE_OK) |
Uh oh!
There was an error while loading. Please reload this page.