Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!sdd.hp.com!hplabs!hpda!hpcupt1!decot From: decot@hpcupt1.cup.hp.com (Dave Decot) Newsgroups: comp.unix.questions Subject: Re: finding out if a directory is empty in C program (was Re: How do I tell when a directory is empty in a script?) Message-ID: <67930008@hpcupt1.cup.hp.com> Date: 13 May 91 18:09:22 GMT References: <1991Apr25.223540.19303@athena.mit.edu> Organization: Hewlett Packard, Cupertino Lines: 20 > Second, stat()ing and checking the link count to find out the number of > subdirectories is a hack that is not guaranteed to work on every system and > that is not required to work according to POSIX (at least, I don't think it > is, although I am interested in being corrected). Operating Systems that > don't really put entries for "." and ".." in a directory (e.g. HP-UX, I > believe) will not have the link counts you're expecting. This is a true characteristic of POSIX, but HP-UX is not an example of systems that do not have actual entries for "." and "..". Only the HP 9000 Series 500 used a directory format (called SDF) in which this was not true, and it was obsoleted several years ago. Even the s500 would fake the existence of these directories if they appeared in a path name, but readdir() and ls(1) would never say that they existed. All modern HP-UX systems have actual entries for "." and ".." . I agree with the poster that portable code should not assume that "." and ".." exist everywhere. Dave Decot