delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/27/04:26:08

Date: Mon, 27 Oct 1997 11:19:36 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: Checking to see if I file exists
In-Reply-To: <62p2v2$1am@sjx-ixn10.ix.netcom.com>
Message-ID: <Pine.SUN.3.91.971027111911.19645E-100000@is>
MIME-Version: 1.0

On 24 Oct 1997, firewind wrote:

> This could be misleading though... fopen() can fail for many more reasons
> than simply, 'file does not exist'...

To be sure that `fopen' failed because the file did not exist, the
code should check if errno == ENOENT.

But I agree that `fopen' is not the best way to test whether a file
exists, primarily because it's a very expensive system call.  `stat'
or `access' are better.  `__file_exists' is better still, but it's
non-portable.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019