Re: File exist
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Apr 2006 11:21:26 +0100
Claude Yih wrote:
Keith Thompson wrote:
ed <ed@xxxxxxxxxxx> writes:On 16 Apr 2006 01:53:03 -0700[...]
paytam@xxxxxxxxx wrote:
Can anyone tell me how can I check that a file exist or no.Try using stat(5).There is no stat() function in standard C. Using it will limit the
portability of your code. See comp.unix.programmer.
I learnt from others that there is a function named access can be used
to detect if a dedicated file exists. The function is as follows:
int access (char* filename, int mode)
For instance, if I wanted to know whether /opt/test.log exists, I would
call this function as
int flag = access("/opt/test.log", 0);
However, this function is included in <io.h>, perhaps it's not a
standard function either.
It is not part of standard C. As I'm sure others have said in this thread standard C does not provide any portable method to see if a file exists. So you can be sure that any method you find goes beyond what standard C provides.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
.
- Follow-Ups:
- Re: File exist
- From: Mr John FO Evans
- Re: File exist
- References:
- File exist
- From: paytam
- Re: File exist
- From: ed
- Re: File exist
- From: Keith Thompson
- Re: File exist
- From: Claude Yih
- File exist
- Prev by Date: Re: File exist
- Next by Date: Re: Comparison function in qsort()
- Previous by thread: Re: File exist
- Next by thread: Re: File exist
- Index(es):
Relevant Pages
|