From owner-freebsd-questions@FreeBSD.ORG Wed Dec 19 03:40:11 2012 Return-Path: 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 950A775 for ; Wed, 19 Dec 2012 03:40:11 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 53AB38FC0C for ; Wed, 19 Dec 2012 03:40:11 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id qBJ3YUVc029288 for ; Tue, 18 Dec 2012 22:34:30 -0500 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id qBJ3YUAs029287; Tue, 18 Dec 2012 22:34:30 -0500 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id F3E10BF24; Tue, 18 Dec 2012 22:34:15 -0500 (EST) To: freebsd-questions@FreeBSD.ORG In-reply-to: <20121219002610.GA12470@ethic.thought.org> (message from Gary Kline on Tue, 18 Dec 2012 16:26:10 -0800) Subject: Re: which C function is best to check for directory EXISTANCE? Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20121219002610.GA12470@ethic.thought.org> Message-Id: <20121219033415.F3E10BF24@kev.msw.wpafb.af.mil> Date: Tue, 18 Dec 2012 22:34:15 -0500 (EST) From: vogelke+unix@pobox.com (Karl Vogel) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 03:40:11 -0000 >> On Tue, 18 Dec 2012 16:26:10 -0800, >> Gary Kline said: G> which C function is best to check for the existence of a *directory*? G> say that I am want to make postitve that "/tmp/foo/" exists. ALso: G> which will make sure that the directory AND file G> "tmp/foo/filename12345" exists and that I have read access to it? I'd just call open() with O_RDONLY and if it fails, check errno for EACCESS (you don't have permission) or ENOENT (doesn't exist). -- Karl Vogel I don't speak for the USAF or my company USELESS PHRASES WHEN SPEAKING TO A COP #9: "You're not gonna check the trunk, are you?"