From owner-freebsd-questions@FreeBSD.ORG Sun Apr 29 22:25:13 2007 Return-Path: X-Original-To: freebsd-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 DA1A816A401; Sun, 29 Apr 2007 22:25:13 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from mailgate04.smtp.vanderbilt.edu (mailgate04.smtp.Vanderbilt.Edu [129.59.1.75]) by mx1.freebsd.org (Postfix) with ESMTP id 8FB6813C45B; Sun, 29 Apr 2007 22:25:13 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from smtp09.smtp.vanderbilt.edu (smtp09.smtp.Vanderbilt.Edu [129.59.1.239]) by mailgate04.smtp.vanderbilt.edu (8.13.8/8.13.8) with ESMTP id l3TLk9IF027726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 29 Apr 2007 16:46:10 -0500 Received: from smtp09.smtp.vanderbilt.edu (localhost [127.0.0.1]) by smtp09.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9C+d3.7.9) with ESMTP id l3TLk9to008321; Sun, 29 Apr 2007 16:46:09 -0500 (CDT) Received: from a140080.n1.vanderbilt.edu (A140080.N1.Vanderbilt.Edu [129.59.140.80]) by smtp09.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9.3B+d3.7.9) with ESMTP id l3TLk8aV008317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 29 Apr 2007 16:46:09 -0500 (CDT) From: Don Hinton Organization: ISIS To: freebsd-questions@freebsd.org Date: Sun, 29 Apr 2007 16:46:02 -0500 User-Agent: KMail/1.9.6 References: <17973.654.765099.201323@jerusalem.litteratus.org> <20070429205848.GA15950@slackbox.xs4all.nl> In-Reply-To: <20070429205848.GA15950@slackbox.xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart21813582.2lYLT75PCR"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200704291646.07563.don.hinton@vanderbilt.edu> X-Proofpoint-Virus-Version: vendor=fsecure engine=4.65.5502:2.3.11, 1.2.37, 4.0.164 definitions=2007-04-29_02:2007-04-27, 2007-04-29, 2007-04-29 signatures=0 X-PPS: No, score=0 Cc: Roland Smith , Robert Huff , 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 22:25:14 -0000 --nextPart21813582.2lYLT75PCR Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sunday 29 April 2007 15:58:48 Roland Smith wrote: > 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? Just open() the path, then pass the fd to getdirentries(), if it returns -1= ,=20 and errno =3D EINVAL, it's not a directory. (man getdirentries for more in= fo) hth... don > > 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 =2D-=20 Don Hinton or Institute for Software Integrated Systems (ISIS), Vanderbilt University tel: 615.480.5667 or 615.870.9728 --nextPart21813582.2lYLT75PCR Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQBGNRIf0U0xbM5cLs0RAnQBAKC5LGPgUUQ1o6XL1ByIMQ1IsvN0PACfUBot ioS01EMZ8h4dQEtSWmj1Ihc= =B60B -----END PGP SIGNATURE----- --nextPart21813582.2lYLT75PCR--