finding out if a directory is empty in C program (was Re: How do I tell when a directory is empty in a script?)
Jonathan I. Kamens
jik at athena.mit.edu
Fri Apr 26 08:35:40 AEST 1991
In article <1991Apr25.022029.5476 at csc.canberra.edu.au>, rvp at softserver.canberra.edu.au (Rey Paulo) writes:
|> Is there any system call or library routine in UNIX which tests whether
|> a directory is empty?
No. You open the directory with opendir() and read it, and if the only
entries in it are "." and "..", it's empty. Just like in a shell script
(except the script uses ls, or shell wildcard expansion, instead of opendir()).
And if you have a system that doesn't have opendir() or something like it,
instead forcing you to open and read the directory file directly, then you
should find your vendor and shoot him.
--
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik at Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8085 Home: 617-782-0710
Disclaimer: If you do find your vendor and shoot him, I'm not responsible. :-)
More information about the Comp.unix.questions
mailing list