python-unrar icon indicating copy to clipboard operation
python-unrar copied to clipboard

Documentation "RAR flag bits" & Request for more predefined methods

Open ganego opened this issue 5 years ago • 1 comments

Hi, documentation says "RAR flag bits". That is nice. It would be also nice if the documentation could link to some place where I can see what those flags are. I cannot find information on it. Here you can find "File flags" and they start at 0x0001, yet unrar returns 0 for all files and 32 for a folder. So that cannot be the correct one.

While at it, why does python-unrar not come with predefined methods like is_file, is_folder, is_encrypted ... ?

ganego avatar Feb 07 '20 19:02 ganego

I also want to ask if there are simple APIs for testing enctryption.

A similar function in zipfile:

            with zipfile.ZipFile(archive_stream) as rd:
                for rf in rd.infolist():
                    is_encrypted = rf.flag_bits & 0x1

The flag_bits can actually offer such information. But using such & bit operation is not safe for users.

Update:

I just came across this API which may solve my problem:

            with rarfile.RarFile(archive_stream) as rd:
                is_encrypted = rd.needs_password()

Vimos avatar Sep 12 '22 03:09 Vimos