Skip to content

Obtain file information via unshield_get_file_descriptor #228

Open

Description

@ScaledLizard

I am the maintainer of ArchiveAccess, an access software for archives:

https://sourceforge.net/projects/archiveaccess/

ArchiveAccess uses libunshield to unpack .cab files. ArchiveAccess provides data about files that can be unpacked, to allow the user to choose what to inspect closer. I currently obtain this information via unshield_get_file_descriptor:

UnshieldFileGroup* file_group = unshield_file_group_get(mUnshieldData, i);
if (file_group != nullptr) {
for (unsigned int j = file_group->first_file; j <= file_group->last_file; j++) {
CPString filename = CPString(unshield_file_name(mUnshieldData, j), (Codepage)fncp);
CPString dirName = CPString(file_group->name, (Codepage)fncp);
FileDescriptor* fd = unshield_get_file_descriptor(mUnshieldData, j);
...
fileInfo.UncompressedFileSize = fd->expanded_size;
fileInfo.CompressedFileSize = fd->compressed_size;
fileInfo.attributes = fd->flags;

In order to do this, I export the function unshield_get_file_descriptor, which is an internal function in official builds. However, a cleaner way to do this would be via proper access functions. I propose to provide several access functions:

uint64_t unshield_get_uncompressed_size(Unshield* unshield, UnshieldFileGroup* file_group, int index);
uint64_t unshield_get_compressed_size(Unshield* unshield, UnshieldFileGroup* file_group, int index);
uint32_t unshield_get_attributes(Unshield* unshield, UnshieldFileGroup* file_group, int index);

There are other ways, like exposing all this data via one function, but these approaches would be less flexible. My questions:

  1. If I would implement this, would you accept it in libunshield, or you would you rather go a different route?
  2. Did I miss that there is a feature for doing this already?

Thanks in advance
Björn

Activity

  1. twogood commented on Apr 8, 2026

    @twogood
    Owner

    Hi Björn,

    I would basically accept this contribution, it just needs to blend in with the existing public API. The current public interface uses unshield_file_ prefix for file information and no existing API takes UnshieldFileGroup* as a parameter.

    We already have unshield_file_size for the uncompressed size, so it could get a sibling for compressed size.

    Regarding unshield_get_attributes I guess we also would need to expose the FILE_* values for the flags. Maybe a name like unshield_file_raw_flags or unshield_file_flags_raw would be more suitable to blend in?

    So maybe these functions?

    uint64_t unshield_file_size_compressed(Unshield* unshield, int index);
    uint32_t/uint16_t unshield_file_flags_raw(Unshield* unshield, int index);

    Cheers,

    David

  2. ScaledLizard commented on Apr 8, 2026

    @ScaledLizard
    ContributorAuthor

    Here is the pull request:

    #230

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions