Mail Archives: djgpp/1998/04/27/20:16:28
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: checking for file existence
|
Date: | Mon, 27 Apr 1998 20:02:27 -0400
|
Organization: | Two pounds of chaos and a pinch of salt.
|
Lines: | 21
|
Message-ID: | <35451C93.222C@cs.com>
|
References: | <6hv7er$5l4$1 AT camel29 DOT mindspring DOT com>
|
NNTP-Posting-Host: | 208.226.48.108
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Eric wrote:
>
> Is there a way to check whether or not a file exists without actually
> opening it?
>
> I have my fopen in a separate encapsulated function. What I want to
> accomplish is the ability to check if a user request for creating a new file
> is on a file that already exists, and if so, provide the option to overwrite
> it (which the encapsulated fopen will do if called).
Use the library function __file_exists(), which is declared in
<unistd.h>. It's a very small, fast routine. There is also a function
named access() which performs more sophisticated checking.
--
---------------------------------------------------------------------
| John M. Aldrich |"A competent and self-confident person|
| aka Fighteer I | is incapable of jealousy in anything.|
| mailto:fighteer AT cs DOT com | Jealousy is invariably a symptom of |
| http://www.cs.com/fighteer | neurotic insecurity." - Lazarus Long|
---------------------------------------------------------------------
- Raw text -