Add two functions to retrieve more file data#230
Conversation
…ressed, unshield_file_flags_raw
| UNSHIELD_API int unshield_file_directory (Unshield* unshield, int index); | ||
| UNSHIELD_API size_t unshield_file_size (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); |
There was a problem hiding this comment.
Would it not make sense to also expose https://github.com/twogood/unshield/blob/main/lib/cabfile.h#L60-L63
otherwise nobody knows what the magic uint16 means?
There was a problem hiding this comment.
Yes, the flags also need to be moved or copied to the public header.
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>
WalkthroughTwo new public API functions are added to expose file metadata: Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
lib/libunshield.h (1)
122-122:⚠️ Potential issue | 🟠 MajorExpose the file flag constants alongside
unshield_file_flags_raw.Without the
FILE_*flag definitions (currently in internallib/cabfile.h), consumers ofunshield_file_flags_rawhave no way to interpret the returneduint16_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
📒 Files selected for processing (2)
lib/file.clib/libunshield.h
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