Re: file exists
- From: guru <guru.jois@xxxxxxxxx>
- Date: 30 May 2007 04:27:56 -0700
On May 30, 1:10 am, "Mr. X." <no_spam_please@xxxxxxxxxxxxxxxxx> wrote:
Hello,
For C, on Lynox -
What is the command that check if the file exists (direct access) ?
Open return -1 if fails, and also lstat,
but I don't know if "fails" means the file doesn't exist.
Thanks :)
What is this lynox..... I suppose it is Linux
you can however check the errno to confirm whether the file exist or
not..
Any way try the access() function. It takes file name and test_type
as argument.
int access (char *file_name, int flag); // return 0 on success and
-1 on error
where flag is symbolic constant defined in fcntl.h or unistd.h (not
sure...may be)
F_OK - file exist
R_OK - readable
W_OK - writable
X_OK - executable
Bye
Guru Jois
.
- References:
- file exists
- From: Mr. X.
- file exists
- Prev by Date: ulimit open file descriptor.
- Next by Date: piping a group of "echo" to a program
- Previous by thread: Re: file exists
- Next by thread: open file or directory
- Index(es):
Relevant Pages
|
|