rm Function

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

Removes a file or directory.

Syntax

 l = rm(fname, ignoreErrors)

Where:

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

It returns True if the process has been succesful or False in case of error.

Example

The following program removes file1:

 PROGRAM rmExample
    USE FU_Files, ONLY: rm
    IMPLICIT NONE
    CHARACTER(LEN=:), ALLOCATABLE :: path
    path='file1'
    IF (rm(path)) THEN
       WRITE(*,*) 'Success'
    ELSE
       WRITE(*,*) 'Error'
    END IF
 END PROGRAM rmExample

Arguments

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

Name of the file or directory to be removed.

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 the process has been succesful. False in case of error.


Contents