Symbolic Link support

Feb 11, 2010 at 10:04 PM

Hi all,

Just wondering if the current 1.9.1.3 support symbolic link feature? I am currently using the .AddSelectedFiles() method and then .Save method to zip up all contains inside a folder. If symbolic link feature support, how do I active it. I looked in the documentation but haven't found anything for that yet.

Thank you,

 

Hugh

Coordinator
Feb 12, 2010 at 2:11 AM

Yes,

There's a property on the ZipFile class called AddDirectoryWillTraverseReparsePoints, which governs the behavior.  By default it is False, meaning your AddSelectedFiles will not traverse reparse points (or symbolic links).  If you set it to True, then your call to AddSelectedFiles will traverse reparse points. 

The documentation is here: http://cheeso.members.winisp.net/DotNetZipHelp/html/99c2673a-65ee-cf82-3fc6-506ed582a7ca.htm

You need at least version 1.9.1.1 to get this feature.

Feb 12, 2010 at 4:00 PM

Hi Cheeso,

Thank you for the quick reply. That's great. I guess this is the NTFS limitation and nothing we can do because the Symbolic Link feature only for directory but not for individual file like Unix version.

 

Hugh

Coordinator
Feb 12, 2010 at 10:36 PM

I misunderstood.  The NTFS supports the idea of a "reparse point", for either a file or a directory.   For a directory, a reparse point is also known as a "junction", and traversing those structures is what is governed by the AddDirectoryWillTraverseReparsePoints propertyI thought you were asking about directory reparse points.

A reparse point for a file is a symlink, an it behaves much like a Unix fs symlink.   http://en.wikipedia.org/wiki/NTFS_symbolic_link

You asked about "symbolic link feature support".   Exactly what did you have in mind?  Currently the AddSelectedFiles() method will follow all symlinks for files.   Would you like this behavior to be modifiable?  Please describe what you would like to see, for "symbolic link feature support".

Feb 14, 2010 at 9:15 PM

But NTFS supports both reparse points (junctions, supported by XP+) and symbolic links (supported by Vista+). Is AddDirectoryWillTraverseReparsePoints method working for both symlinks and junctions?

Coordinator
Feb 14, 2010 at 11:15 PM

> But NTFS supports both reparse points (junctions, supported by XP+) and symbolic links

Yes, I understand that NTFS supports symlinks.  As I wrote above, a reparse point on a file is a symlink.  Your statement implies that symlinks are not reparse points, but that's not true.

> Is AddDirectoryWillTraverseReparsePoints method working for both symlinks and junctions?

No, Craccoon.

As I said above, Currently the AddSelectedFiles() method will follow all symlinks for files.

I propose to extend the selection criteria to include the ability to distinguish between regular files and symbolic links.  Specifically I'll use the attributes noun  and I'll add another letter: L for symbolic link.  The set of attributes will be H,R,S,A,I,L.  For Hidden, Readonly, System, Archive, NotContentIndexed and Link.

So you will be able to call AddSelectedFiles() with selection criteria like "attributes = L" to add only files that are symbolic links, or
"attributes != L" to add files that are not symbolic links. 

This is what I propose to do.  It's not in the library yet.

 

Coordinator
Feb 14, 2010 at 11:48 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 19, 2010 at 10:13 PM
Cheeso wrote:

I misunderstood.  The NTFS supports the idea of a "reparse point", for either a file or a directory.   For a directory, a reparse point is also known as a "junction", and traversing those structures is what is governed by the AddDirectoryWillTraverseReparsePoints propertyI thought you were asking about directory reparse points.

A reparse point for a file is a symlink, an it behaves much like a Unix fs symlink.   http://en.wikipedia.org/wiki/NTFS_symbolic_link

You asked about "symbolic link feature support".   Exactly what did you have in mind?  Currently the AddSelectedFiles() method will follow all symlinks for files.   Would you like this behavior to be modifiable?  Please describe what you would like to see, for "symbolic link feature support".

Sorry, for the slow response I was out for the past few days. What I am after is the way to preserve the symlink from unix environment. 

Ex: let say I have 3 files that suppose to be identical to each other named file1.txt, file2.txt and file3.txt. When I make modification to either of the file listed, all the other one are changed as well. So I only need to modify 1 file and all 3 files that symbolic link to each other get change. 

For whatever reason, when I put the source files on a windows machine, the symlink got remove and those 3 files are no longer linked together. Change 1 file will effect any other file that original linked together.

Coordinator
Feb 19, 2010 at 10:52 PM

I understand what a symlink is. 

I don't know what you mean by "put the source files on the windows machine" .

Also, I didn't see any mention of a zip file anywhere in your description.  Here's the thing: a zip file cannot store a symlink.  It stores files or directories.  There is no possibility to store a symlink in a zip file.  The format does not handle it.   If you want symlinks, then consider a different archive format, one that can store a symlink, like TAR.  But if you choose TAR, you need the right TAR tool or library in order to unpack the symlink as a symlink.  Not all tar tools handle symlinks.