[Mono-dev] File.Copy on unix with symbolic link

Dick Porter dick at ximian.com
Mon Mar 5 05:27:19 EST 2007


On Mon, 2007-03-05 at 07:31 +0100, lorenzo wrote:
> I'm developing a backup utility and this involves the use of File.Copy static 
> method to make a copy of a file to another file.
> 
> On Windows:
> a link to another file or directory ( the .lnk extension file ) is copied as 
> is to destination.
> 
> On Linux:
> a link to another file or directory ( the symlink ) is dereferenced and the 
> destination result in the dereferenced file or directory.
> 
> Why is used this implementation of the File.Copy w/symlink on Unix?
> The application work very different if I execute the same IL code on different 
> platform. Is necessary to mantain this different behavior?

POSIX symlinks and windows lnk files are two completely different
concepts.  In fact, I believe the latest version of windows has support
for symlinks too.  See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/symbolic_link_effects_on_file_systems_functions.asp

(I don't think we completely match the behaviour of the MS runtime wrt
symlinks, and fixing it would require figuring out how they map the .net
calls to the windows system calls.)

> 
> Is there another solution to make a symlink copied as a symlink without using 
> Mono.Unix libraries?

Not at the moment.

- Dick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070305/77173708/attachment.bin 


More information about the Mono-devel-list mailing list