[UP]


Manual Reference Pages  - system_perm (3)

NAME

system_perm(3f) - [M_system:QUERY_FILE] get file type and permission as a string (LICENSE:PD)

CONTENTS

Synopsis
Description
Return Value
Example
Author
License

SYNOPSIS

function system_perm(mode) result (perms)

   integer(kind=int64),intent(in)   :: MODE
   character(len=:),allocatable :: PERMS

DESCRIPTION

The system_perm(3f) function returns a string containing the type and permission of a file implied by the value of the mode value.

RETURN VALUE

PERMS returns the permission string in a format similar to that used by Unix commands such as ls(1).

EXAMPLE

Sample program:

   program demo_system_perm
   use M_system, only : system_perm, system_stat
   use,intrinsic     :: iso_fortran_env, only : int64
   implicit none
   character(len=4096) :: string
   integer(kind=int64)     :: values(13)
   integer             :: ierr
   character(len=:),allocatable :: perms
      values=0
      ! get pathname from command line
      call get_command_argument(1, string)
      ! get pathname information
      call system_stat(string,values,ierr)
      if(ierr.eq.0)then
         ! convert permit mode to a string
         perms=system_perm(values(3))
         ! print permits as a string, decimal value, and octal value
         write(*,’("for ",a," permits[",a,"]",1x,i0,1x,o0)’) &
          & trim(string),perms,values(3),values(3)
      endif
   end program demo_system_perm

Results:

   demo_system_perm /tmp

for /tmp permits[drwxrwxrwx --S] 17407 41777

AUTHOR

John S. Urban

LICENSE

Public Domain


system_perm (3) March 11, 2021
Generated by manServer 1.08 from 48328cd0-343a-4072-8b48-71e9861d6370 using man macros.