<div><br></div><div><br></div><br><div class="gmail_quote">On Mon, Apr 15, 2013 at 12:28 PM, Bengt Kleberg <span dir="ltr"><<a href="mailto:bengt.kleberg@ericsson.com" target="_blank">bengt.kleberg@ericsson.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings,<br>
<br>
How does the existing filelib:fold_files/5 fail your requirements?<br></blockquote><div><br></div><div><div>Because it loops.</div><div><br></div><div>I have a symlink in a directory pointing to '..'</div><div><div>
<br></div><div>$ ls -l bugs</div><div>total 12</div><div>-rw-r--r-- 1 ejoearm rnd 1168 Apr 15 12:37 bug.beam</div><div>-rw-r--r-- 1 ejoearm rnd 514 Apr 15 12:36 bug.erl</div><div>-rw-r--r-- 1 ejoearm rnd 184 Apr 15 12:21 bug.erl~</div>
<div>lrwxrwxrwx 1 ejoearm rnd 2 Apr 15 12:20 share -> ..</div></div><div><br></div><div>I tried this</div><div><br></div><div>test1() -></div><div> filelib:fold_files("/home/ejoearm/work",</div><div>
<span class="Apple-tab-span" style="white-space:pre"> </span> ".*",</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> fun visit/2,</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> 0).</div><div><br></div><div>visit(F, N) -></div><div> io:format("~p: ~p~n",[N, F]),</div><div> N+1.</div><div><br></div><div>So then I run this I see:</div>
<div><br></div><div><br></div><div><div>730: "/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/bugs/bug.erl~"</div><div>731: "/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/bugs/bug.beam"</div>
<div>732: "/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/rules.erl"</div><div>733: "/home/ejoearm/work/bugs/share/bugs/share/bugs/share/bugs/share/test.erl"</div></div><div><br></div><div>
I only want to follow the symlink once - not multiple times</div><div><br></div><div>/Joe</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
bengt<br>
<div><div class="h5"><br>
On Mon, 2013-04-15 at 12:17 +0200, Joe Armstrong wrote:<br>
> Hello,<br>
><br>
><br>
> Has anybody written a decent "file finder" in Erlang. Something like<br>
> the unix 'find' command.<br>
><br>
><br>
> I want something that:<br>
><br>
><br>
> - traverse the file system recursively<br>
> - applies a function to any filename that matches a regexp<br>
> - correctly handles symlinks<br>
> - should work on all platforms<br>
><br>
><br>
> I'd like to follow symlinks, but not when they result in a circular<br>
> path.<br>
><br>
><br>
> I thought I had one, but it turns out not to correctly handle symlinks<br>
><br>
><br>
> /Joe<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>