diff options
author | LemonBoy <thatlemon@gmail.com> | 2022-04-28 15:26:33 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-28 15:26:33 +0100 |
commit | dca1d40cd0f2af0755519e7028378bd3c8fefd31 (patch) | |
tree | 3c045bcc898b033399fd9d5fe4ec884ef70c58e2 /runtime | |
parent | 68a573ce2b996602a86b14d9b258ebb8c657604f (diff) |
patch 8.2.4838: checking for absolute path is not trivialv8.2.4838
Problem: Checking for absolute path is not trivial.
Solution: Add isabsolutepath(). (closes #10303)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 19 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index bfb18eda66..1b091b16f8 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -295,6 +295,7 @@ inputsecret({prompt} [, {text}]) String like input() but hiding the text insert({object}, {item} [, {idx}]) List insert {item} in {object} [before {idx}] interrupt() none interrupt script execution invert({expr}) Number bitwise invert +isabsolutepath({path}) Number |TRUE| if {path} is an absolute path isdirectory({directory}) Number |TRUE| if {directory} is a directory isinf({expr}) Number determine if {expr} is infinity value (positive or negative) @@ -4672,6 +4673,24 @@ invert({expr}) *invert()* < Can also be used as a |method|: > :let bits = bits->invert() +isabsolutepath({directory}) *isabsolutepath()* + The result is a Number, which is |TRUE| when {path} is an + absolute path. +< On Unix, a path is considered absolute when it starts with '/'. + On MS-Windows, it is considered absolute when it starts with an + optional drive prefix and is followed by a '\' or '/'. UNC paths + are always absolute. + Example: > + echo isabsolutepath('/usr/share/') " 1 + echo isabsolutepath('./foobar') " 0 + echo isabsolutepath('C:\Windows') " 1 + echo isabsolutepath('foobar') " 0 + echo isabsolutepath('\\remote\file') " 1 + + Can also be used as a |method|: > + GetName()->isabsolutepath() + + isdirectory({directory}) *isdirectory()* The result is a Number, which is |TRUE| when a directory with the name {directory} exists. If {directory} doesn't diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index e9e16fe546..a9a1fcd883 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -904,6 +904,7 @@ System functions and manipulation of files: getfperm() get the permissions of a file setfperm() set the permissions of a file getftype() get the kind of a file + isabsolutepath() check if a path is absolute isdirectory() check if a directory exists getfsize() get the size of a file getcwd() get the current working directory |