[erlang-questions] Best way to check if a given directory is empty (or not)?

Michael Turner michael.eugene.turner@REDACTED
Tue Mar 13 14:03:11 CET 2012


If it's any consolation, Ruby hackers are also stumped.

  http://www.ruby-forum.com/topic/84762

-michael turner

On Tue, Mar 13, 2012 at 8:32 PM, Edward Wang <edward.yu.wang@REDACTED> wrote:
> There might be an obvious solution. That is, if certain file is bound to be
> present out of that 150k files, then you can just check the presence of that
> particular file.
>
> On Mar 13, 2012 2:10 PM, "Zabrane Mickael" <zabrane3@REDACTED> wrote:
>>
>> Hi guys,
>>
>> I'd like to know if there's a good and portable method to check if a
>> directory is empty (or not)?
>> In my case, the directory can contains huge number (more than 150K in
>> average) of files if it is not empty.
>>
>> I've tested the following working calls:
>> a. file:list_dir/1
>> b. filelib:wildcard/2
>>
>> The problem with them is they both return a list of filenames.
>> I'd like to avoid getting this list back to be able to check if it's empty
>> or not.
>>
>> Advices please?
>>
>> Regards
>> Zabrane
>> _______________________________________________
>> 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
>



More information about the erlang-questions mailing list