Mail Archives: djgpp/1997/08/23/17:35:05
Hello,
how can i inspect if a file exists?
I'm using the function following function; is there a better one?
/* returns 1 if file exists and 0 otherwise */
int file_exists(char *name)
{
FILE *fp;
int v = 0;
if ((fp = fopen(name, "rb")) != NULL) { /* if file opens */
if (fclose(fp) != 0) { /* close file */
printf("ed: error handling %s\n", name); /* can't close file
*/
exit(2); /* bye */
} /* file closed */
v = 1; /* file exists
(return 1) */
}
return v; /* end */
}
Marco Monteiro
back to a simtel site and try
getting at least the latest binutils, that is
where 'as' comes from.
Andrew
- Raw text -