[Mono-dev] Replacement for Mono.Unix.UnixFile.TryReadLink

Paolo Molaro lupus at ximian.com
Wed Jan 11 11:25:05 EST 2006


On 01/11/06 Jonathan Pryor wrote:
> > The behaviour of TryReadLink and
> > UnixSymbolicLinkInfo.ContentsPath seems to be the same. Wanted to
> > counter check if this is indeed the case.
> 
> Those aren't direct equivalents.  UnixSymbolicLinkInfo.ContentsPath is
> equivalent to UnixFile.ReadLink() -- it will throw an exception if there
> was an error reading the link.  UnixFile.TryReadLink() can be simulated:
> 
>         // 1.1.12 Code:
>         string target = UnixFile.TryReadLink ("sym-link");
>         
>         // 1.1.13 Code:
>         UnixSymbolicLinkInfo symlink = new UnixSymbolicLinkInfo ("sym-link");
>         string target = symlink.HasContents ? symlink.ContentsPath : null;

Why is the first method obsoleted, though? It's way clearer and likely
faster, too.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list