ajaybc
ajaybc

Reputation: 4059

Maintain file and folder permissions inside archives

I am packaging and distributing a program I made for Windows,Linux and Mac. I plan to put the files and folders in zip archives.

If I set the correct folder and file permissions and then compress into zip and redistribute them, will those permissions be maintained when the user extracts them in Linux or Mac systems ? Or do they have to set the permissions themselves ?

Upvotes: 28

Views: 33603

Answers (2)

aemus
aemus

Reputation: 723

An installer is your best option here. Lets me explain a bit better why.

Windows has these permissions:

Modify
Read & Execute
Read
Write

Which are assigned to Groups or Usernames,

Unix based systems have:

Read
Write 
Execute

Which can be assigned to owner, group and others.

Has you can see, its difficult to map permissions from one system to another, since the filesystems handle permissions differently.

However some zip utilities like Info-Zip supports Unix based filesystem features, such as user and group IDs, file permissions, and support for symbolic links. It also support NTFS filesystem permissions, and will make an attempt to translate from NTFS permissions to Unix permissions or vice-versa when extracting files. This can result in potentially unintended combinations, e.g. .exe files being created on NTFS volumes with executable permission denied.*

If you are planning on distributing your program, an installer is indeed your best solution.

*From wikipedia: Zip (file format)

Upvotes: 3

larsks
larsks

Reputation: 312370

zip does not store file permissions in the archive.

tar archives will preserve file permissions on Linux and OS X. I have no idea what happens on Windows. If you can test things out on Windows and it works, this is probably your best bet. It probably depends on what tool people use to unpack the archives.

Another option would be to create an installer, although there are few non-commercial options for creating cross-platform installers. Wikipedia has a list.

Upvotes: 7

Related Questions