Mono Class Library: Mono.Unix.UnixSymbolicLinkInfo Overview | MembersMono.Unix.UnixSymbolicLinkInfo.Contents Property |
Gets the target of this symbolic link. [Edit]
|
A Mono.Unix.UnixFileSystemInfo reference containing information about the target of this symbolic link, or null if UnixFileSystemInfo.FullName:
- does not exist, or
- is not a symbolic link.
The behavior will be changed in the future to generate an exception for either of the above error conditions, so current code needs to deal with both exceptions and a null return value. null will not be used by the Mono 1.2 release.
[Edit]
Type Reason ArgumentException UnixFileSystemInfo.FullName is not a symbolic link. [Mono.Unix.Native.Errno.EINVAL] [Edit] System.IO.DirectoryNotFoundException A component of UnixFileSystemInfo.FullName is not a directory. [Mono.Unix.Native.Errno.ENOTDIR] [Edit] System.IO.FileNotFoundException UnixFileSystemInfo.FullName [Mono.Unix.Native.Errno.ENOENT] [Edit] System.IO.IOException An I/O error occurred while reading from the file system. [Mono.Unix.Native.Errno.EIO] [Edit] System.IO.PathTooLongException A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. [Mono.Unix.Native.Errno.ENAMETOOLONG] [Edit] Mono.Unix.UnixIOException Search permission is denied for a component of the path prefix. [Mono.Unix.Native.Errno.EACCES]
-or-
Too many symbolic links were encountered in translating the pathname. [Mono.Unix.Native.Errno.ELOOP]
[Edit]
Note: Do not use this method, as it always creates a new Mono.Unix.UnixFileSystemInfo instance -- no caching is performed, even though it's a property. Instead, use UnixSymbolicLinkInfo.GetContents,This really should throw the same exceptions as UnixSymbolicLinkInfo.ContentsPath instead of returning null.
Note: The target may in turn be a symbolic link (nothing prevents symbolic links from referencing other symbolic links). To get the actual target, use UnixPath.GetRealPath, UnixPath.GetCompleteRealPath, or walk the symbolic link "chain":[Edit]
C# Example UnixFileSystemInfo target = new UnixSymbolicLinkInfo ("symlink").Contents; while (target != null && target.FileType == FileTypes.SymbolicLink) { target = ((UnixSymbolicLinkInfo) target).Contents; }
Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0