[erlang-questions] file finders
Joe Armstrong
erlang@REDACTED
Mon Apr 15 12:42:43 CEST 2013
On Mon, Apr 15, 2013 at 12:28 PM, Bengt Kleberg
<bengt.kleberg@REDACTED>wrote:
> Greetings,
>
> How does the existing filelib:fold_files/5 fail your requirements?
>
Because it loops.
I have a symlink in a directory pointing to '..'
$ ls -l bugs
total 12
-rw-r--r-- 1 ejoearm rnd 1168 Apr 15 12:37 bug.beam
-rw-r--r-- 1 ejoearm rnd 514 Apr 15 12:36 bug.erl
-rw-r--r-- 1 ejoearm rnd 184 Apr 15 12:21 bug.erl~
lrwxrwxrwx 1 ejoearm rnd 2 Apr 15 12:20 share -> ..
I tried this
test1() ->
filelib:fold_files("/home/ejoearm/work",
".*",
true,
fun visit/2,
0).
visit(F, N) ->
io:format("~p: ~p~n",[N, F]),
N+1.
So then I run this I see:
730:
"/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/bugs/bug.erl~"
731:
"/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/bugs/bug.beam"
732:
"/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/rules.erl"
733:
"/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/test.erl"
I only want to follow the symlink once - not multiple times
/Joe
>
>
> bengt
>
> On Mon, 2013-04-15 at 12:17 +0200, Joe Armstrong wrote:
> > Hello,
> >
> >
> > Has anybody written a decent "file finder" in Erlang. Something like
> > the unix 'find' command.
> >
> >
> > I want something that:
> >
> >
> > - traverse the file system recursively
> > - applies a function to any filename that matches a regexp
> > - correctly handles symlinks
> > - should work on all platforms
> >
> >
> > I'd like to follow symlinks, but not when they result in a circular
> > path.
> >
> >
> > I thought I had one, but it turns out not to correctly handle symlinks
> >
> >
> > /Joe
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130415/635f1b1e/attachment.htm>
More information about the erlang-questions
mailing list