Re: file exists



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

.



Relevant Pages

  • file exists
    ... 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. ...
    (comp.unix.programmer)
  • Re: [opensuse] No GUI 10.3 new install
    ... xorg.conf with this command (if you have nano installed otherwise ... of first boot startup the display flashes 3 times with about 5 sec ... need to restart after correction is done. ... start its own gui which also fails. ...
    (SuSE)
  • Re: [opensuse] No GUI 10.3 new install
    ... xorg.conf with this command (if you have nano installed otherwise ... of first boot startup the display flashes 3 times with about 5 sec ... need to restart after correction is done. ... start its own gui which also fails. ...
    (SuSE)
  • Re: Domain Controller Cannot Locate Group Policy
    ... > command lines suggest some problem similar to what eventviewer shows: ... > - ping myserver.my.domain.com works ... > - net view \\my.domain.com FAILS ...
    (microsoft.public.win2000.active_directory)
  • Re: How to use BAT file in SMS 2003 to update Register in client PC.
    ... It runs but fails with a failure exit code? ... Also, in your command line, what is S:\ drive? ... > I am trying to update/change Register information of client PCs by SMS ... > Software Distribution function from BAT file. ...
    (microsoft.public.sms.swdist)