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++ 3.0r4 - <b>access</b> 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. 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>
   #include <stdlib.h>


   int main()
   {
       if ((access("temp.fil",F_OK)) == -1) {
           perror("File 'temp.fil' does not exist");
           return EXIT_FAILURE;
       } else
           printf("File 'temp.fil' found\n");
       return EXIT_SUCCESS;
   }


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


See Also: fstat open stat

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