Manual Reference Pages  - system_access (3m_system)

NAME

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

CONTENTS

Synopsis
Description
Options
Return Value
Examples

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

EXAMPLES

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

Results:

 >   does /usr/bin/bash exist?     T
 >   is /usr/bin/bash readable?      T
 >   is /usr/bin/bash writable?      F
 >   is /usr/bin/bash executable?    T
 >   does /tmp/NOTTHERE exist?     F
 >   is /tmp/NOTTHERE readable?      F
 >   is /tmp/NOTTHERE writable?      F
 >   is /tmp/NOTTHERE executable?    F
 >   does /usr/local exist?     T
 >   is /usr/local readable?      T
 >   is /usr/local writable?      F
 >   is /usr/local executable?    T
 >   does . exist?     T
 >   is . readable?      T
 >   is . writable?      T
 >   is . executable?    T
 >   does PROBABLY_NOT exist?     F
 >   is PROBABLY_NOT readable?      F
 >   is PROBABLY_NOT writable?      F
 >   is PROBABLY_NOT executable?    F


Nemo Release 3.1 system_access (3m_system) March 07, 2025
Generated by manServer 1.08 from ec52b7f0-7a91-4a5e-903f-7421063a0732 using man macros.