On Sun, Apr 29, 2007 at 04:39:42PM -0400, Robert Huff wrote:
>       In C code, is there a quick and dirty way to tell if a path
> points to a directory?  Or do I have to open the parent directory and
> check the entry for that name?

Try opening the path in question for writing with open(2). If it returns
-1, and errno is EISDIR, it is a directory.

This will be inconclusive on a read-only filesystem, or if the limit of
open file handles is reached, or for any other reason that can make
open(2) fail.

R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)

Attachment: pgp82o0Z9g4ES.pgp
Description: PGP signature

Reply via email to