The path dir/name of the first directory in dirs (separated by ';' or
':', except a ':' after a drive letter) that has name, or ''.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
file name |
||
| character(len=*), | intent(in) | :: | dirs |
directories, separated by ';' or ':' |
function find_in_dirs(name, dirs) result(path) character(len=*), intent(in) :: name !! file name character(len=*), intent(in) :: dirs !! directories, separated by ';' or ':' character(len=:), allocatable :: path integer :: i, j logical :: exists path = '' i = 1 do while (i <= len(dirs)) j = i do while (j <= len(dirs)) if (dirs(j:j) == ';' .or. (dirs(j:j) == ':' .and. j > i + 1)) exit ! ':' not after a drive letter j = j + 1 end do if (j > i) then inquire(file=dirs(i:j-1)//'/'//name, exist=exists) if (exists) then path = dirs(i:j-1)//'/'//name return end if end if i = j + 1 end do end function find_in_dirs