Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2012 22:34:15 -0500 (EST)
From:      vogelke+unix@pobox.com (Karl Vogel)
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: which C function is best to check for directory EXISTANCE?
Message-ID:  <20121219033415.F3E10BF24@kev.msw.wpafb.af.mil>
In-Reply-To: <20121219002610.GA12470@ethic.thought.org> (message from Gary Kline on Tue, 18 Dec 2012 16:26:10 -0800)
References:  <20121219002610.GA12470@ethic.thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
>> On Tue, 18 Dec 2012 16:26:10 -0800, 
>> Gary Kline <kline@thought.org> 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?"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121219033415.F3E10BF24>