[Mono-list] UnixDirectoryInfo::IsSymbolicLink does not work properly
jonpryor at vt.edu
Sun Apr 4 16:40:48 EDT 2010
On Sat, 2010-04-03 at 18:56 +0200, cimodev wrote:
> \on my machine (OpenSuse 11.2 with Mono 2.6) both
> IsSymbolicLink-Properties from UnixDirectoryInfo and UnixFileInfo return
> always false, even on symbolic links i've just created for testing.
This is by design. UnixDirectoryInfo and UnixFileInfo use the stat(2)
function, which "dereferences" symbolic links (thus returning
file/directory information for the *target* of the symbolic link).
If you want information about the symbolic link itself, you need to use
the lstat(2) function, which is what UnixSymbolicLinkInfo does.
If you want to get the appropriate *Info type for a path, use
UnixFileSystemInfo.GetFileSystemEntry(string), which will create a
UnixDirectoryInfo for directories (S_IFDIR is set), a
UnixSymbolicLinkInfo for symbolic links (S_IFLNK is set), and a
UnixFileInfo for everything else.
More information about the Mono-list