Skip to content

Preserve file permissions when unzipping #90

Description

@AnHeuermann

Hey,

I'm using ZipFile.jl to unzip some files on a Linux system. Is it possible to preserve the permissions of the original files?
I can't find permissions in ZipFile.ReadableFile and therefore when writing the files I don't know which files need only read/write permissions and which additional execute permissions.

I guess one would need to add something to ZipFile.ReadableFile and get the mode from zlib. But I'm note sure if zlib offers a function to do that.

How to reproduce

Create a zip file

$ mkdir myZip
$ touch myZip/script.sh
$ chmod +rwx myZip/script.sh
$ ls -la myZip/script.sh 
-rwxrwxr-x 1 username groupname 0 Aug  1 16:33 myZip/script.sh
$ zip myZip -r
$ zip -r myZip.zip myZip/

unzip preserves permissions

$ unzip myZip.zip -d unzipped/
$ ls -la unzipped/myZip/script.sh 
-rwxrwxr-x 1 username groupname 0 Aug  1 16:33 unzipped/myZip/script.sh

Where could I find file permissions

julia> using ZipFile
julia> archive = ZipFile.Reader("myZip.zip")
ZipFile.Reader for IOStream(<file myZip.zip>) containing 2 files:

uncompressedsize method  mtime            name
----------------------------------------------
               0 Store   2022-08-01 16-33 myZip/
               0 Store   2022-08-01 16-33 myZip/script.sh
julia> archive.files[2]
ZipFile.ReadableFile(name=myZip/script.sh, method=Store, uncompresssedsize=0, compressedsize=0, mtime=1.659364424e9)

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions