home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / extra / access.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  481 b   |  28 lines

  1. #include <fcntl.h>
  2. #include <unistd.h>
  3. #include <dos/dos.h>
  4. #ifdef __GNUC__
  5. #include <inline/dos.h>
  6. #endif
  7.  
  8. extern void __seterrno(void);
  9. extern char *__amigapath(const char *path);
  10.  
  11. int access (const char *name,int mode)
  12. { BPTR lock;
  13.  
  14. #ifdef IXPATHS
  15.   if((name=__amigapath(name))==NULL)
  16.     return -1;
  17. #endif
  18.  
  19.   lock=Lock((char *)name,mode&(O_WRONLY|O_RDWR)?ACCESS_WRITE:ACCESS_READ);
  20.   if(lock!=0l)
  21.   { UnLock(lock);
  22.     return 0;
  23.   }else
  24.   { __seterrno();
  25.     return -1; }
  26. }
  27.   
  28.