system_perm(3f) - [M_system:QUERY_FILE] get file type and permission as a string (LICENSE:PD)
Synopsis
Description
Return Value
Examples
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 ! 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_permResults:
demo_system_perm /tmpfor /tmp permits[drwxrwxrwx --S] 17407 41777
John S. Urban
Public Domain
Nemo Release 3.1 | system_perm (3m_system) | March 07, 2025 |