Re: testing for directory
- From: Roland Smith <rsmith@xxxxxxxxx>
- Date: Sun, 29 Apr 2007 22:58:48 +0200
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.
Roland
--
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:
pgpWnpVB2anz1.pgp
Description: PGP signature
- Follow-Ups:
- Re: testing for directory
- From: Don Hinton
- Re: testing for directory
- References:
- testing for directory
- From: Robert Huff
- testing for directory
- Prev by Date: testing for directory
- Next by Date: Re: freebsd installation server (nfs/ftp/http) local network
- Previous by thread: testing for directory
- Next by thread: Re: testing for directory
- Index(es):
Relevant Pages
|
|