system_perm(3f) - [M_system] get file type and permission as a string (LICENSE:PD)
Synopsis
Description
Return Value
Example
Author
License
function system_perm(mode) result (perms)integer(kind=int64),intent(in) :: MODE character(len=:),allocatable :: PERMS
The system_perm(3f) function returns a string containing the type and permission of a file implied by the value of the mode value.
PERMS returns the permission string in a format similar to that used by Unix commands such as ls(1).
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 call get_command_argument(1, string) ! get pathname from command line call system_stat(string,values,ierr) ! get pathname information if(ierr.eq.0)then perms=system_perm(values(3)) ! convert permit mode to a string ! 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_permResults:
demo_system_perm /tmpfor /tmp permits[drwxrwxrwx --S] 17407 41777
John S. Urban
Public Domain
system_perm (3) | July 05, 2020 |