[UP]


Manual Reference Pages  - system_access (3)

NAME

system_access(3f) - [M_system:QUERY_FILE] checks accessibility or existence of a pathname (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Return Value
Example

SYNOPSIS

elemental impure logical function system_access(pathname,amode)

   character(len=*),intent(in) :: pathname
   integer,intent(in)          :: amode

DESCRIPTION

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).

OPTIONS

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.

RETURN VALUE

If not true an error occurred or the requested access is not granted

EXAMPLE

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


system_access (3) March 11, 2021
Generated by manServer 1.08 from 1944302d-62e9-4550-ae7f-39c794b55cc6 using man macros.