Re: How do I check the existence of a file programmatically in C?q~~.

From: Rich Teer (rich.teer_at_rite-group.com)
Date: 09/01/05


Date: Thu, 01 Sep 2005 15:27:12 GMT

On Wed, 31 Aug 2005, doomster@gmail.com wrote:

> I want to check to see if a file exists before I try to open it. If it
> doesn't exist, I will report an error.

This is nearly always a bad idea. Just let the open fail if the file
doesn't exist. WHy? COnsider this time line if you use access() or
the like:

Proc A Proc B
access (succeeds)
                                                Deletes file
open (fails even though you think it won't)

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich


Relevant Pages