Skip to content

Commit b8c8b81

Browse files
committed
added interfaces
1 parent a8519b6 commit b8c8b81

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/stdlib_system.F90

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ module stdlib_system
9393
public :: split_path
9494
public :: base_name
9595
public :: dir_name
96+
public :: is_abs
97+
public :: abs_path
9698

9799
!! version: experimental
98100
!!
@@ -781,6 +783,46 @@ module function dir_name_string(p) result(dir)
781783
end function dir_name_string
782784
end interface dir_name
783785

786+
interface is_abs
787+
!! version: experimental
788+
!!
789+
!!### Summary
790+
!! This function checks if the path is absolute.
791+
!! ([Specification](../page/specs/stdlib_system.html#is_abs))
792+
!!
793+
!!### Description
794+
!! This function checks if the path is absolute (i.e not relative).
795+
!! - On POSIX systems this means the path starts with `/`.
796+
!! - On Windows systems this means the path is either an UNC path (like `\\host\path\share`) or
797+
!! a path starting with a drive letter (like `C:\Users\`)
798+
module logical function is_abs_char(p)
799+
character(len=*), intent(in) :: p
800+
end function is_abs_char
801+
802+
module logical function is_abs_string(p)
803+
type(string_type), intent(in) :: p
804+
end function is_abs_string
805+
end interface is_abs
806+
807+
interface abs_path
808+
!! version: experimental
809+
!!
810+
!!### Summary
811+
!! This function returns the absolutized version of the provided path.
812+
!! ([Specification](../page/specs/stdlib_system.html#abs_path))
813+
!!
814+
module function abs_path_char(p, err) result(abs_p)
815+
character(len=*), intent(in) :: p
816+
type(state_type), optional, intent(out) :: err
817+
character(len=:), allocatable :: abs_p
818+
end function abs_path_char
819+
820+
module function abs_path_string(p, err) result(abs_p)
821+
type(string_type), intent(in) :: p
822+
type(state_type), optional, intent(out) :: err
823+
type(string_type) :: abs_p
824+
end function abs_path_string
825+
end interface abs_path
784826

785827
contains
786828

0 commit comments

Comments
 (0)