Manual Reference Pages - system_isreg (3m_system)
NAME
system_isreg(3f) - [M_system:QUERY_FILE] checks if argument is a
regular file
(LICENSE:PD)
CONTENTS
Synopsis
Description
Options
Return Value
Errors
See Also
Examples
SYNOPSIS
elemental impure logical function system_isreg(pathname)
character(len=*),intent(in) :: pathname
logical :: system_isreg
DESCRIPTION
The isreg(3f) function checks if path is a regular file
OPTIONS
|
path |
a character string representing a pathname. Trailing spaces
are ignored.
|
|
RETURN VALUE
The system_isreg() function should always be successful and no
return value is reserved to indicate an error.
ERRORS
No errors are defined.
SEE ALSO
system_islnk(3f), system_stat(3f), system_isdir(3f), system_perm(3f)
EXAMPLES
check if filename is a regular file
program simple
use M_system, only : system_isreg
implicit none
integer :: i
character(len=80),parameter :: names(*)=[ &
/tmp , &
test.txt , &
~/.bashrc , &
.bashrc , &
. ]
do i=1,size(names)
write(*,*) is ,trim(names(i)), a regular file? , &
& system_isreg(names(i))
enddo
end program simple
EXTENDED EXAMPLE
list readable non-hidden regular files and links in current directory
program demo_system_isreg
use M_system, only : isreg=>system_isreg, islnk=>system_islnk
use M_system, only : access=>system_access, R_OK
use M_system, only : system_dir
implicit none
character(len=:),allocatable :: filenames(:)
logical,allocatable :: mymask(:)
integer :: i
! list readable non-hidden regular files and links in current directory
! make list of all files in current directory
filenames=system_dir(pattern=*)
! select regular files and links
mymask= isreg(filenames).or.islnk(filenames)
! skip hidden directories in those
where(mymask) mymask=filenames(:)(1:1).ne..
! select readable files in those
where(mymask) mymask=access(filenames,R_OK)
filenames=pack(filenames,mask=mymask)
write(*,(a))(trim(filenames(i)),i=1,size(filenames))
end program demo_system_isreg
| Nemo Release 3.1 | system_isreg (3m_system) | March 07, 2025 |
Generated by manServer 1.08 from 8b565ecb-efc9-4a81-88f1-756c7f61bef8 using man macros.