ACCESS(3F) COMMAND REFERENCE ACCESS(3F) NAME access - determine accessability of a file SYNOPSIS integer function access (filename, mode) character*(*) filename, mode DESCRIPTION Access checks the filename, for accessability with respect to the caller according to mode. Mode may include, in any order and in any combination, one or more of the following: r Test for read permission w Test for write permission x Test for execute permission (blank)Test for existence An error code is returned if either argument is illegal, or if the file cannot be accessed in all of the specified modes. 0 is returned if the specified access would be successful. EXAMPLES The following FORTRAN subroutine Openfn illustrates how the access function might be used to open a file for writing. The access function is called to check if filename already exists. If the file does not exist, unit number 7 is opened for writing and the subroutine is exitted with errno as nonzero; otherwise an error message is printed to standard error and the routine is exitted with errno set to zero. SUBROUTINE Openfn (filename, errno) CHARACTER*(*) filename INTEGER errno, access errno = access (filename " ") IF (errno .NE. 0) THEN OPEN (7, FILE=filename, STATUS='NEW') ELSE WRITE (0, 900) 'File ''', filename, ''' already exists.' ENDIF 900 FORMAT (A6, A, A17) RETURN END Note that the same result can be obtained with the error specifier (ERR=) and the input/output status specifier (IOSTAT=) within the open statement. Printed 5/12/88 1
ACCESS(3F) COMMAND REFERENCE ACCESS(3F) FILES /usr/lib/libU77.a f77 UTek system interface library. CAVEATS Pathnames can be no longer than MAXPATHLEN as defined in /usr/include/max.h . SEE ALSO access(2) and perror(3f). Printed 5/12/88 2
%%index%% na:312,94; sy:406,790; de:1196,804; ex:2000,1642; fi:4026,191; ca:4217,195; se:4412,182; %%index%%000000000122