[erlang-questions] symlink error (I think)

Dave Peticolas dave@REDACTED
Sun Apr 14 21:10:18 CEST 2013


2013/4/14 Joe Armstrong <erlang@REDACTED>

> I have a troublesome symlink that puts one of my programs into a loop
>
> If I list the files in my troublesome directory I see this:
>
> ls -l /Users/joe/projects/fuse/fuserl-2.0.5/fw
> total 8
> drwxr-xr-x@  6 joe  staff  204 Jul 23  2009 bin
> drwxr-xr-x@  3 joe  staff  102 Jul 23  2009 build
> drwxr-xr-x@ 19 joe  staff  646 Jul 23  2009 m4
> drwxr-xr-x@  4 joe  staff  136 Jul 23  2009 package
> drwxr-xr-x@  5 joe  staff  170 Jul 23  2009 revision
> drwxr-xr-x@  9 joe  staff  306 Jul 23  2009 sh
> lrwxr-xr-x   1 joe  staff    2 Oct 16  2011 share -> ..
> drwxr-xr-x@  7 joe  staff  238 Jul 23  2009 template
>
> So share is a link to '..'
>
> But file:read_file_info thinks 'share' is a directory
>
>
> -module(bug).
> -compile(export_all).
>
> -include_lib("kernel/include/file.hrl").
>
> test() ->
>     {ok, X} =
> file:read_file_info("/Users/joe/projects/fuse/fuserl-2.0.5/fw/share"),
>     X#file_info.type.
>
> Running this
>
> > bug:test()
> directory.
>
> I'd expected this to return symlink
>
> This is on a macbook OS X 10.8.3
>
> Is this a bug, or have I misunderstood something
>

I believe file:read_file_info/1,2 will "follow" symlinks and give you
information
about whatever the link is pointing to. To get information about the link
itself
use file:read_link_info/1,2 instead. Despite the name, that function will
also
work on non-links, in which case you get the same information as
file:read_file_info/1,2



> Cheers
>
> /Joe
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
--Dave Peticolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130414/25b17d2b/attachment.htm>


More information about the erlang-questions mailing list