Skip to content

Feature: py7zlib: archive file mode and format API #62

@miurahr

Description

@miurahr

It is better that py7zlib have an API to retrieve file modes.
I've been working for it and PR soon.

And I'd like to propose supporting Unix file mode (rwx)
p7zip on UNIX has an attribute trick to store a file mode, when FILE_ATTRIBUTE_UNIX_EXTENSION bit is set, then store a mode in high 16bit.

https://github.com/warexify/p7zip/blob/master/CPP/7zip/Archive/7z/7zUpdate.cpp#L882

 // p7zip uses the trick to store posix attributes in high 16 bits
      if (ui.Attrib & 0x8000)
      {
        unsigned st_mode = ui.Attrib >> 16;
// st_mode = 00111;

Here is a proposal of API design.

f = fp.getmember(name)
if f.is_executable():
    print("%s is an executable" % name)
if f.is_readonly():
    print("%s is a read only file" % name)

There are some design issue that how it should be in Windows platform.
A question is whether it checks unix attribute extension only on Unix/Linux/Mac, or always checks it on any platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions