home *** CD-ROM | disk | FTP | other *** search
- /* -*-c,save-*- */
- /*
- * access.c - *Real* access function
- * Robert Heller. Created: Sun Apr 13, 1986 16:59:10.47
- * Last Mod:
- *
- * (c) Copyright 1986 by Robert Heller
- * All Rights Reserved
- *
- *
- */
- #include <stdio.h>
- #include <osif.h>
- #include <osiferr.h>
- #include <errno.h>
-
- #define IFEXISTS 0
- #define IFEXECUTE 1
- #define IFWRITE 2
- #define IFREAD 4
-
- access(filename,mode)
- register char *filename;
- register int mode;
- {
- register int fd;
- register int status;
- register struct fcbtab *scratchfcb;
-
- fd = open(filename,0);
- if (fd == -1) return(-1);
- scratchfcb = (&_fds[fd].fcb.drive);
- if (mode != IFWRITE) {
- close(fd);
- return(0);
- }
- if (isatty(fd) == 1 || (scratchfcb->ftype[0] & 0x0080) == 0) status = 0;
- else status = -1;
- close(fd);
- if (status == -1) errno = EACCES;
- return(status);
- }
-