Skip to content

Conversation

@hysw
Copy link
Collaborator

@hysw hysw commented Jan 6, 2026

  • Add a "dive aware" archive extractor.
    • Only extract relevant files, and discard directory hierarchy of the archive.
  • Extract content to temp file if we opened an archive.
  • Update path lookup logic.

@hysw hysw force-pushed the open_zip branch 3 times, most recently from f20b3d9 to ef28701 Compare January 6, 2026 21:51
@hysw hysw marked this pull request as ready for review January 6, 2026 21:53
@hysw
Copy link
Collaborator Author

hysw commented Jan 6, 2026

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.

@hysw hysw marked this pull request as draft January 6, 2026 23:09
- 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)>;
Copy link
Collaborator

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)
Copy link
Collaborator

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

Suggested change
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)
Copy link
Collaborator

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

Suggested change
if (auto res = WriteArchiveEntry(dst_file, reader.get()); res != ARCHIVE_OK)
if (WriteArchiveEntry(dst_file, reader.get()) != ARCHIVE_OK)

Comment on lines +128 to +129
if (auto res = archive_read_open_filename(reader.get(), m_path.string().c_str(), kBlockSize);
res != ARCHIVE_OK)
Copy link
Collaborator

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

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants