system_access(3f) - [M_system:QUERY_FILE] checks accessibility or existence of a pathname (LICENSE:PD)
Synopsis
Description
Options
Return Value
Examples
elemental impure logical function system_access(pathname,amode)
character(len=*),intent(in) :: pathname integer,intent(in) :: amode
The system_access(3f) function checks pathname existence and access permissions. The function checks the pathname for accessibility according to the bit pattern contained in amode, using the real user ID in place of the effective user ID and the real group ID in place of the effective group ID.
The value of amode is either the bitwise-inclusive OR of the access permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).
pathname a character string representing a directory pathname. Trailing spaces are ignored. amode bitwise-inclusive OR of the values R_OK, W_OK, X_OK, or F_OK.
If not true an error occurred or the requested access is not granted
check if filename is accessible
Sample program:program demo_system_access use M_system, only : system_access, F_OK, R_OK, W_OK, X_OK implicit none integer :: i character(len=80),parameter :: names(*)=[ & /usr/bin/bash , & /tmp/NOTTHERE , & /usr/local , & . , & PROBABLY_NOT ] do i=1,size(names) write(*,*) does ,trim(names(i)), exist? , & & system_access(names(i),F_OK) write(*,*) is ,trim(names(i)), readable? , & & system_access(names(i),R_OK) write(*,*) is ,trim(names(i)), writable? , & & system_access(names(i),W_OK) write(*,*) is ,trim(names(i)), executable? , & & system_access(names(i),X_OK) enddo end program demo_system_access
Nemo Release 3.1 | system_access (3) | February 23, 2025 |