From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/fio/access.x | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sys/fio/access.x (limited to 'sys/fio/access.x') diff --git a/sys/fio/access.x b/sys/fio/access.x new file mode 100644 index 00000000..6a7db09d --- /dev/null +++ b/sys/fio/access.x @@ -0,0 +1,58 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include +include +include + +# ACCESS -- Determine the accessiblity of a file. Use "access(file,0,0)" +# to determine if a file exists. Specify the mode and/or type to see if +# the file is accessible in a certain mode, and to verify the type of the file. + +int procedure access (fname, mode, type) + +char fname[ARB] # filename +int mode # file access mode (0 if dont care) +int type # file type (txt|bin) (0 if dont care) + +int zmode, status, fd, ip +int fstati(), fstdfile() +include +include "mmap.inc" +errchk fmapfn +define exit_ 91 + +begin + status = NO + + # Ignore any whitespace at the beginning of the filename. + for (ip=1; IS_WHITE (fname[ip]); ip=ip+1) + ; + + # Special handling is required for the pseudofiles STDIN, STDOUT, etc. + if (fname[ip] == 'S') { + if (fstdfile (fname[ip], fd) == YES) { + if (mode == 0 || mode == fstati (fd, F_MODE)) + if (type == 0 || type == fstati (fd, F_TYPE)) { + status = YES + goto exit_ + } + goto exit_ + } + } + + # Regular files. If the filename cannot be mapped the file does not + # exist (or the filename mapping file is lost or unreadable). + + iferr (call fmapfn (fname[ip], pathname, SZ_PATHNAME)) + goto exit_ + + zmode = mode + if (mode >= READ_ONLY && mode <= TEMP_FILE) + zmode = mmap[mode] + call zfacss (pathname, zmode, type, status) + +exit_ + return (status) +end -- cgit