Re: File exist



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.

.



Relevant Pages

  • Re: Newbie question about double precision
    ... I got bitten nastily by this one once, and learnt ... better in a similar manner to you. ... It would be nice if such tags were unnecessary, but the standard is ... equal to zero. ...
    (comp.lang.fortran)
  • Re: Battle standard
    ... learnt in WoW?" ... When I read it I was like "Hey haha I know all these" ... But this post humbles me:( ... still i've never even seen anyone use a standard - ever. ...
    (alt.games.warcraft)
  • Re: File exist
    ... There is no statfunction in standard C. Using it will limit the ... portability of your code. ... int access ... As I'm sure others have said in this thread standard C does not provide any portable method to see if a file exists. ...
    (comp.lang.c)
  • Re: File exist
    ... There is no statfunction in standard C. Using it will limit the ... portability of your code. ... int access ... As I'm sure others have said in this thread standard C does not provide any portable method to see if a file exists. ...
    (comp.lang.c)
  • Re: File exist
    ... There is no statfunction in standard C. Using it will limit the ... portability of your code. ... int access ... thread standard C does not provide any portable method to see if a file ...
    (comp.lang.c)