fdoc

functionresolve_path

character(len=:) function resolve_path(base, path) result(out)

The absolute form of path relative to directory base, with variables expanded and . and .. removed, and with / as the separator on paths with a drive letter. Links are left as they are, and the path does not have to exist.

Arguments

NameTypeIntentAttributesDescription
basecharacter(len=*)in

directory for relative paths

pathcharacter(len=*)in

the path

Result

NameTypeAttributesDescription
outcharacter(len=:)privateallocatable

Calls

Source

Show the code
function resolve_path(base, path) result(out)
    character(len=*), intent(in) :: base    !! directory for relative paths
    character(len=*), intent(in) :: path    !! the path
    character(len=:), allocatable :: out, head
    integer :: k

    head = expand_vars(path)
    if (.not. has_root(head)) head = absolute_path(join_path(base, head))
    if (has_drive(head)) then
        do k = 1, len(head)
            if (head(k:k) == '\') head(k:k) = '/'
        end do
    end if
    out = lexical_clean(head)
end function resolve_path

Graphs

Calls

Called by