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

Miles Fidelman <>
Tue Mar 13 16:57:22 CET 2012


um...

given an empty directory:

7> file:list_dir("/Users/mfidelman/empty") == {ok,[]}.
true

given a non-empty directory:
8> file:list_dir("/Users/mfidelman") == {ok,[]}.
false

note:
file:list_dir seems to do the right thing with invisible files - with an 
invisible file in ../empty
9> file:list_dir("/Users/mfidelman/empty") == {ok,[]}.
false
10> file:list_dir("/Users/mfidelman/empty").
{ok,[".foo"]}


Miles Fidelman

-- 
In theory, there is no difference between theory and practice.
In practice, there is.   .... Yogi Berra





More information about the erlang-questions mailing list