From owner-freebsd-questions@FreeBSD.ORG Sun Apr 29 20:58:50 2007 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A678416A404 for ; Sun, 29 Apr 2007 20:58:50 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr2.xs4all.nl (smtp-vbr2.xs4all.nl [194.109.24.22]) by mx1.freebsd.org (Postfix) with ESMTP id 4002413C45D for ; Sun, 29 Apr 2007 20:58:50 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr2.xs4all.nl (8.13.8/8.13.8) with ESMTP id l3TKwmpx080547; Sun, 29 Apr 2007 22:58:49 +0200 (CEST) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id 29530B854; Sun, 29 Apr 2007 22:58:48 +0200 (CEST) Date: Sun, 29 Apr 2007 22:58:48 +0200 From: Roland Smith To: Robert Huff Message-ID: <20070429205848.GA15950@slackbox.xs4all.nl> References: <17973.654.765099.201323@jerusalem.litteratus.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline In-Reply-To: <17973.654.765099.201323@jerusalem.litteratus.org> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.15 (2007-04-06) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: questions@freebsd.org Subject: Re: testing for directory X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2007 20:58:50 -0000 --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--