1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <knet.h>
include <ctype.h>
include <config.h>
include <fio.h>
include <fset.h>
# 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 <fio.com>
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
|