rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
611 stars 112 forks source link

[Feature Request]: Getting CRC32 information from files #104

Closed RScherzer closed 1 year ago

RScherzer commented 1 year ago

Feature description

Maybe I did oversee it but is there no getter to receive the crc32 hash information from the stored files in the archive? Name is there in BitArchiveItem and others...but no crc32? Would be great if you can make it available (at least for zip/7z/rar).

...update...I mean without recalculating the crc32 hash value on the data, just a getter for the crc32 values (if available) stored in the archived files structures

Additional context

No response

Code of Conduct

rikyoz commented 1 year ago

Hi!

Maybe I did oversee it but is there no getter to receive the crc32 hash information from the stored files in the archive?

There's no direct getter for the crc32 checksum. However, you can get the CRC32 hash of an archive's item as follows:

uint32_t crc32 = 0;
auto crc_property = item.getProperty( BitProperty::CRC ); // BitPropVariant object
if ( crc_property.isUInt32() ) { // Just to be sure that the variant value has the correct type.
    crc32 = crc_property.getUInt32();
}

As far as I know, CRC32 variant values returned by 7-zip are either of UInt32 or Empty type, so you might need to check only if !crc_property.isEmpty().

Would be great if you can make it available (at least for zip/7z/rar).

I will definitely add a getter to the item's class in a future version of the library!

...update...I mean without recalculating the crc32 hash value on the data, just a getter for the crc32 values (if available) stored in the archived files structures

As far as I know, the CRC property provided by 7-zip is the one stored in the archive file structures.

Hope that helps!

RScherzer commented 1 year ago

works perfectly fine, thanks

rikyoz commented 1 year ago

No problem! :D