views:

67

answers:

1

I zipped a rails project from OS X and sent it to a colleague who works on Windows. He updated the 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

+3  A: 

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").

Michael Aaron Safyan
I don't understand how `hg` can preserve permission flags. Isn't `.hg` just another folder inside the project tree? So, does it mean I should zip and send the `.hg` folder only, instead of the whole project tree? Thanks
ohho
@Horace, no. You push/pull changes between your repositories. All these version control systems store metadata, and the push/pull in addition to the metadata should preserve the permissions.
Michael Aaron Safyan