<div>
Not a good solution if other apps are using the directory, but if it's just your app you could call file:del_dir() - if it's empty, it will return ok if not you'll get an {error,eexist} error. No idea on the performance characteristics, but suspect it's pretty good...</div>
<div><div><br></div><div>-- </div>Steve Strong<div>@srstrong</div><div><br>Sent with <a href="http://www.sparrowmailapp.com/?sig">Sparrow</a></div><div><br></div></div>
<p style="color: #A0A0A8;">On Tuesday, 13 March 2012 at 07:09, Zabrane Mickael wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div>Hi guys,</div><div><br></div><div>I'd like to know if there's a good and portable method to check if a directory is empty (or not)?</div><div>In my case, the directory can contains huge number (more than 150K in average) of files if it is not empty.</div><div><br></div><div>I've tested the following working calls:</div><div>a. <a href="file:list">file:list</a>_dir/1</div><div>b. filelib:wildcard/2</div><div><br></div><div>The problem with them is they both return a list of filenames.</div><div>I'd like to avoid getting this list back to be able to check if it's empty or not.</div><div><br></div><div>Advices please?</div><div><br></div><div>Regards</div><div>Zabrane</div><div>_______________________________________________</div><div>erlang-questions mailing list</div><div><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></div><div><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>