Skip to content

Add two functions to retrieve more file data - #230

Merged
twogood merged 7 commits into
twogood:mainfrom
ScaledLizard:pr-file-accessors
Oct 18, 2026
Merged

twogood merged 7 commits into
twogood:mainfrom
ScaledLizard:pr-file-accessors

Conversation

@ScaledLizard

@ScaledLizard ScaledLizard commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Add two functions to retrieve more file data: unshield_file_size_compressed, unshield_file_flags_raw.

Since the functions return uint64_t and uint16_t, we should also add this:

#include <stdint.h>

Summary by CodeRabbit

  • New Features
    • Added new API functions to access compressed file sizes from archives
    • Added new API functions to access raw file flags from archives

Comment thread lib/libunshield.h Resolved
Comment thread lib/file.c Resolved
Comment thread lib/file.c Resolved
Let's have consistent signatures and potentially fix these in twogood#227

Co-authored-by: Steffen Pankratz <kratz00@gmx.de>
Signed-off-by: David Eriksson <david@activout.se>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8d3aa4a-cc6b-4f3e-8e8d-4d4d2e692e72
📥 Commits

Reviewing files that changed from the base of the PR and between de20f1c and be006ed.

📒 Files selected for processing: 3
  • lib/cabfile.h
  • lib/file.c
  • lib/libunshield.h

Walkthrough

Two new public API functions are added to expose file metadata: unshield_file_size_compressed() retrieves the compressed file size, and unshield_file_flags_raw() retrieves raw file flags. Both follow existing error-handling patterns and return default values on lookup failure.

Changes

Cohort / File(s) Summary
New Accessor Functions
lib/libunshield.h, lib/file.c
Added two new public API functions for querying file metadata: unshield_file_size_compressed() returning uint64_t and unshield_file_flags_raw() returning uint16_t. Includes header with <stdint.h> for fixed-width integer types.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding two new accessor functions (unshield_file_size_compressed and unshield_file_flags_raw) to retrieve additional file metadata from the public API.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

🐰 Two new friends hop into the fold,
Compressed sizes and flags to be told,
Simple and clean, they follow the way,
Of accessor functions here to stay! ✨

Comment @coderabbitai help to get the list of available commands.

@twogood

twogood commented Apr 17, 2026 •

Copy link
Copy Markdown
Owner

It seems I had commented the below on #227 instead of this PR, sorry about that!

Let's fix the warnings in the other PR [#227] (with or without adding UNSHIELD_API) and don't add UNSHIELD_API in this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
lib/libunshield.h (1)

122-122: ⚠️ Potential issue | 🟠 Major

Expose the file flag constants alongside unshield_file_flags_raw.

Without the FILE_* flag definitions (currently in internal lib/cabfile.h), consumers of unshield_file_flags_raw have no way to interpret the returned uint16_t. Please move/copy the relevant flag constants (e.g. FILE_COMPRESSED, FILE_INVALID, FILE_SPLIT, FILE_OBFUSCATED) into this public header so the new accessor is actually usable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/libunshield.h` at line 122, Add the file flag constants used by
unshield_file_flags_raw to the public header so callers can interpret the
returned uint16_t: copy or move the relevant definitions (e.g. FILE_COMPRESSED,
FILE_INVALID, FILE_SPLIT, FILE_OBFUSCATED and any associated bit masks) from
internal lib/cabfile.h into lib/libunshield.h, ensure they use the same integer
types and values as the originals, and keep them guarded by the same visibility
macro (UNSHIELD_API or plain defines) so consumers can include libunshield.h and
decode the flags returned by unshield_file_flags_raw.
🧹 Nitpick comments (1)
lib/libunshield.h (1)

121-122: Optional: align declarations with the existing column layout.

Neighboring declarations (lines 115–120) align return types into a fixed column; the two new lines break that alignment and push the parameter list out. Purely cosmetic — feel free to ignore.

Proposed tweak
-UNSHIELD_API uint64_t    unshield_file_size_compressed(Unshield* unshield, int index);
-UNSHIELD_API uint16_t    unshield_file_flags_raw      (Unshield* unshield, int index);
+UNSHIELD_API uint64_t    unshield_file_size_compressed (Unshield* unshield, int index);
+UNSHIELD_API uint16_t    unshield_file_flags_raw       (Unshield* unshield, int index);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/libunshield.h` around lines 121 - 122, The two new declarations
unshield_file_size_compressed and unshield_file_flags_raw break the header's
column alignment; update their spacing to match the existing declaration layout
(align the return types and push parameter lists into the same column as other
prototypes) so they visually line up with the neighboring declarations like the
ones at lines 115–120; adjust spaces between UNSHIELD_API, the return type
(uint64_t / uint16_t), the function name, and the parameter list to follow the
established column alignment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@lib/libunshield.h`:
- Line 122: Add the file flag constants used by unshield_file_flags_raw to the
public header so callers can interpret the returned uint16_t: copy or move the
relevant definitions (e.g. FILE_COMPRESSED, FILE_INVALID, FILE_SPLIT,
FILE_OBFUSCATED and any associated bit masks) from internal lib/cabfile.h into
lib/libunshield.h, ensure they use the same integer types and values as the
originals, and keep them guarded by the same visibility macro (UNSHIELD_API or
plain defines) so consumers can include libunshield.h and decode the flags
returned by unshield_file_flags_raw.

---

Nitpick comments:
In `@lib/libunshield.h`:
- Around line 121-122: The two new declarations unshield_file_size_compressed
and unshield_file_flags_raw break the header's column alignment; update their
spacing to match the existing declaration layout (align the return types and
push parameter lists into the same column as other prototypes) so they visually
line up with the neighboring declarations like the ones at lines 115–120; adjust
spaces between UNSHIELD_API, the return type (uint64_t / uint16_t), the function
name, and the parameter list to follow the established column alignment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bedb9870-a1a1-4c0b-a022-510ba54c6d86

📥 Commits

Reviewing files that changed from the base of the PR and between cbed3d1 and de20f1c.

📒 Files selected for processing (2)
  • lib/file.c
  • lib/libunshield.h

@twogood twogood self-assigned this Apr 17, 2026
ScaledLizard and others added 2 commits October 18, 2026 19:16
Let's have consistent signatures and potentially fix these in twogood#227

Co-authored-by: Steffen Pankratz <kratz00@gmx.de>
Signed-off-by: David Eriksson <david@activout.se>
@twogood

twogood commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

What this change does: Adds accessors for compressed size and raw file flags. Compressed size is useful to library clients inspecting archives without extracting them.

Should fix: Publish and document the flag constants alongside unshield_file_flags_raw(). Currently the relevant FILE_* values live in the private cabfile.h, so public-header-only clients receive an undocumented integer and must copy internal definitions. The existing PR discussion already identifies this gap. Include small accessor checks, especially for invalid indices and zero-length files.

The existing macOS suite passed (24/24). I found no new extraction regression in the accessor implementation. #227 also contains these accessors, so the two PRs overlap.

Verdict: A useful, modest contribution. Merge with the flag definitions/documentation and keep the accessor addition in this PR.


Branch update correction: The initial update used a force-pushed rebase. The original PR commits have now been restored as first-parent history with a merge commit, pushed normally without force. Both the original and previously rebased commits remain reachable. The reviewed file contents are unchanged.

Review basis: main 313534b (after #199), with current logging, assertions, I/O callbacks, and GCC 14/15 CI preserved in conflict resolutions. No functional fixes to the findings above were folded into the branch update. Local checks used macOS arm64, shared Debug builds with bundled MD5 unless stated otherwise; native MSVC and glibc runtime checks were not performed.

Restore the original contribution commits as the first-parent history.
Keep the reviewed conflict resolutions and current main without rewriting published history again.
@twogood
twogood merged commit feaa32f into twogood:main Oct 18, 2026
8 checks passed
@twogood

twogood commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thanks @ScaledLizard !

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.

3 participants