Date: Sun, 29 Apr 2007 22:58:48 +0200 From: Roland Smith <rsmith@xs4all.nl> To: Robert Huff <roberthuff@rcn.com> Cc: questions@freebsd.org Subject: Re: testing for directory Message-ID: <20070429205848.GA15950@slackbox.xs4all.nl> In-Reply-To: <17973.654.765099.201323@jerusalem.litteratus.org> References: <17973.654.765099.201323@jerusalem.litteratus.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 29, 2007 at 04:39:42PM -0400, Robert Huff wrote: >=20 > 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 --=20 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) --SLDf9lqlvOQaIe6s Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) iD8DBQFGNQcIEnfvsMMhpyURAifHAJ9e3sAecRnNrGHaBrib79QINn5FogCgkaa4 YF6CKg1TsIedby43qBKlU4U= =TWXf -----END PGP SIGNATURE----- --SLDf9lqlvOQaIe6s--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070429205848.GA15950>