home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / ACCESS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  540 b   |  28 lines

  1. /* access.c (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <errno.h>
  5. #include <io.h>
  6.  
  7. int access (const char *name, int mode)
  8. {
  9.   int a;
  10.  
  11.   a = __chmod (name, 0, 0);
  12.   if (a < 0)
  13.     return (-1);
  14.   if (a & _A_SUBDIR)        /* directories are always readable and writable */
  15.     return (0);
  16.   if (a & _A_VOLID)
  17.     {
  18.       errno = ENOENT;
  19.       return (-1);
  20.     }
  21.   if ((mode & 2) && (a & _A_RDONLY))
  22.     {
  23.       errno = EACCES;
  24.       return (-1);
  25.     }
  26.   return (0);
  27. }
  28.