[erlang-questions] Best way to check if a given directory is empty (or not)?
Tue Mar 13 23:26:37 CET 2012
On Mar 13, 2012, at 11:59 PM, Richard O'Keefe wrote:
>> On unix systems link_count=2 means, that directory is empty:
> No it doesn't. It means that the directory has no *subdirectories*.
Mental note to myself - verify before posting;)
Sorry for confusion!
Yes - thats correct. Link count > 2 means, that there are subdirectories.
(On unix, mac os x behaves differently).
Richard's opendir/readir C code is only reasonably portable way.
Similar implementation for windows with _findfirst/_findnext is at
C-code and port/NIF are way to go.
"We should forget about small efficiencies, about 97 percent of the time.
Premature optimization is the root of all evil." Donald Knuth
+372 5656 9996
More information about the erlang-questions