[erlang-questions] file finders

Bengt Kleberg <>
Mon Apr 15 12:58:25 CEST 2013


Would it not be better to file a bug report on filelib:fold_files/5?
Maybe even accompanied by a patch?


bengt

On Mon, 2013-04-15 at 12:42 +0200, Joe Armstrong wrote:
> 
> 
> 
> 
> 
> On Mon, Apr 15, 2013 at 12:28 PM, Bengt Kleberg
> <> 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
>         > 
>         > http://erlang.org/mailman/listinfo/erlang-questions
>         
>         _______________________________________________
>         erlang-questions mailing list
>         
>         http://erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list