开发者

File permissions changed between OS X and Windows

开发者 https://www.devze.com 2022-12-30 18:06 出处:网络
I zipped a rails project from OS X and sent it to a colleague who works on Windows. He updated the开发者_C百科 source, zipped the whole project folder and sent the zip file back to me.

I zipped a rails project from OS X and sent it to a colleague who works on Windows. He updated the开发者_C百科 source, zipped the whole project folder and sent the zip file back to me.

After unzipping the project, I found that the file permissions information is kind of lost. For example, the script/server is changed from -rwxr-xr-x to -rw-r--r--. Is there a way to preserver the file permission flags, when transferring files between mac and windows?

Thanks


The ZIP file format does not preserve permissions. The *.tar (and *.tar.bz2 and *.tar.gz) formats do preserve permissions; however, most Windows machines don't understand them out of the box and there is no guarantee that when they are untarred and then retarred that the permissions will be preserved (but if you untar the archive on any other UNIX machine, they will have the same permissions as when they were originally tarred). But, since you are collaborating on source code files, you really should be using some sort of Version Control System (VCS) also known as Source Code Management (SCM). There are several possible options depending on whether you prefer a Centralized Version Control System (CVCS) or a Distributed Version Control System (DVCS). For CVCS, the Subversion (SVN) version control system is an obvious choice. For DVCS, both Git and Mercurial are worth considering. To the best of my understanding, these version control systems will preserve the permissions (or they allow the permissions to be explicitly set via properties -- e.g. "svn:executable").


ZIP does contain file permissions, but all programs I have come across only saves the permissions of the files as they are when zipped, on the OS and file system they are zipped from. Thus on Windows there will be no r/w/x flags, only directories (directories are not always saved as separate entries, "compressed folder" in windows does not).

I made a command line utility to be able to set files as executable within a ZIP because I wanted to create release files valid on MacOS and Linux from Windows. The files created will work correctly on all 3 OS.

The utility can be downloaded from http://www.galaxy-forces.com/zip_exec.zip. The c++ source is available from the same site.

Hope it will help someone.

/Ronnie

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号