Determines the extension of a file given its name or path.
l = extension(fname)
Where:
fname
: Name or path of the file the determine the extension.It returns the extension of the file including the "dot". Empty path is returned if no extension is found.
The following program gets the extensions of some files
PROGRAM extensionExample
USE FU_Files, ONLY: extension
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path
path='file1.txt'
WRITE(*,*) path, ' ', extension(path)
path='./file1.txt'
WRITE(*,*) path, ' ', extension(path)
path='/tmp/file1.txt'
WRITE(*,*) path, ' ', extension(path)
path='/tmp/file1'
WRITE(*,*) path, ' ', extension(path)
END PROGRAM extensionExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fname |
Filename or path to a file. |
Extension of the file including the "dot". Empty path is returned if no extension is found.