Removes the filename from a path. It is similar to function parent_path but this one does not remove trailing path separators (if any).
l = remove_filename(fname)
Where:
fname
: Name or path of the file.It returns the fname value with the filename removed.
The following program removes the filename of some paths.
PROGRAM remove_filenameExample
USE FU_Files, ONLY: remove_filename
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path
path='file1.txt'
WRITE(*,*) path, ' ', remove_filename(path)
path='./file1.txt'
WRITE(*,*) path, ' ', remove_filename(path)
path='/tmp/file1.txt'
WRITE(*,*) path, ' ', remove_filename(path)
path='/tmp/file1.dat'
WRITE(*,*) path, ' ', remove_filename(path)
path='/tmp/file1'
WRITE(*,*) path, ' ', remove_filename(path)
END PROGRAM remove_filenameExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fname |
Filename or path to a file. |
The fname value with the filename removed.