is_regular_file Function

public function is_regular_file(fname, ignoreErrors) result(res)

Checks if a regular file exists and it is not a directory, etc. It follows symlinks.

Syntax

 l = is_regular_file(fname, ignoreErrors)

Where:

  • fname: Name of the file to be checked.
  • ignoreErrors: False to print a detailed description of the error message. Optional parameter. Default is False.

It returns True if fname is a regular file and false otherwise.

Example

The following program checks the if a file is a regular file or not:

 PROGRAM is_regular_fileExample
    USE FU_Files, ONLY: is_regular_file
    IMPLICIT NONE
    CHARACTER(LEN=:), ALLOCATABLE :: path
    path='file1'
    IF (is_regular_file(path)) THEN
       WRITE(*,*) 'It is a file'
    ELSE
       WRITE(*,*) 'It is not a file'
    END IF
 END PROGRAM is_regular_fileExample

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fname

Name of the file to be checked.

logical, intent(in), optional :: ignoreErrors

False to print a detailed description of the error message. Optional parameter. Default is False.

Return Value logical

True if fname is a regular file. False otherwise.


Contents