Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - access http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   access

   Usage
   #include <io.h>
   int access(char *path, int mode)

   Description
   access  determines  whether the file or directory  specified  by  path
   exists  and can be accessed in the file mode specified by  mode.  Note
   that under MSDOS all directories have both read and write permission.

   Possible values for mode are:
   F_OK      Check for existence only
   X_OK      Check for execute permission
   W_OK      Check for write permission
   R_OK      Check for read permission

   Mode can be combined using the bitwise or operator, thus:
   W_OK | R_OK
   Check for read and write permission

   Example
   #include <io.h>
   #include <stdio.h>

   main()
   {
        if((access("temp.fil",F_OK)) == -1)
        {
             perror("File 'temp.fil' does not exist");
        else
             printf("File 'temp.fil' found\n");
        }
   }
   Return Value
   Returns 0 if the file exists and can be accessed in mode. A value of -
   1  means that the file does not exist or cannot be accessed  in  mode,
   and errno is set.


See Also: fstat open stat

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson