home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-18.59-src.tgz / emacs-18.59-src.tar / fsf / emacs18 / amiga / unix / src / access.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  506b  |  30 lines

  1. #include "amiga.h"
  2. #include "fibstat.h"
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5.  
  6. #undef access
  7.  
  8. int __access(const char *name, int mode)
  9. {
  10.   int ret = -1;
  11.   struct stat sbuf;
  12.  
  13.   chkabort();
  14.   if (_fibstat(name, &sbuf) == 0)
  15.     {
  16.       int fmode = (sbuf.st_mode & (S_IREAD | S_IEXEC)) >> 6 |
  17.     (sbuf.st_mode & (S_IWRITE >> 3)) >> 3;
  18.  
  19.       if ((fmode & mode) == mode) ret = 0;
  20.       else errno = EACCES;
  21.     }
  22.   return ret;
  23. }
  24.  
  25. int access(const char *name, int mode)
  26. {
  27.   return __access(name, mode);
  28. }
  29.  
  30.