feat: path functions is_abs and abs_path#1027
feat: path functions is_abs and abs_path#1027wassup05 wants to merge 6 commits intofortran-lang:masterfrom
is_abs and abs_path#1027Conversation
There was a problem hiding this comment.
Thanks, @wassup05!
I'm wondering if is_abs_path may be better to use. While "path" is the first thing many will think of from context, it is entirely implied. Even in the use statement stdlib_system, only: is_abs, it's not visible (c.f. Python's os.path.isabs).
|
I had that in mind too @sebastian-mutz, and I have changed it now. |
sebastian-mutz
left a comment
There was a problem hiding this comment.
LGTM with the recent change, @wassup05. Many thanks.
| end if | ||
|
|
||
| ! join the cwd and path | ||
| abs_p = cwd / p |
There was a problem hiding this comment.
what happens if p is already an absolute path on input?
| call split_path(p, dir, temp) | ||
| end function dir_name_string | ||
|
|
||
| module logical function is_abs_path_char(p) |
There was a problem hiding this comment.
the is_abs_path function only tests the form of a path specification, not the fact that it must actually exist in the filesystem. So I wonder if giving these functions the same name as is_file, is_directory etc., that instead test the actual filesystem, wouldn't be confusing for some. Also, do other library implementations only check the form, or do they require the actual path to exist?
User facing functions added are:
is_abs(path): returns alogicalindicating if the path is absolute.abs_path(path [, err]): returns the absolutized version of the path.is_absdoes pure string manipulation checking ifpathstarts with/UNCpath or starts with a drive letter likeC:\abs_pathperforms a syscall to get the current working directory and thenjoinsit to thepath, returning thejoinedpathPrior Art
os.path.abspath(Python)os.path.isabs(Python)