aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-08-18 18:53:03 -0400
committerGitHub <noreply@github.com>2016-08-18 18:53:03 -0400
commit6f0f8e7f4abd7a238250b71f8de208ff81e78d9c (patch)
tree62fd524dece5b2b8d1b131f367e6cf2e375eef0e /src/nvim/path.c
parentae6db26b0956f4a30185cfe0294143e73a37052e (diff)
parentccb6af064fe879dc8e213a582f7f938ad1972ae3 (diff)
downloadrneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.tar.gz
rneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.tar.bz2
rneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.zip
Merge #5198 from equalsraf/windows-path-is-absolute
Windows: path_is_absolute()
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index c20dffa9b1..a2617973b1 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2186,9 +2186,16 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf,
/// Check if the given file is absolute.
///
-/// This just checks if the file name starts with '/' or '~'.
/// @return `TRUE` if "fname" is absolute.
int path_is_absolute_path(const char_u *fname)
{
+#ifdef WIN32
+ // A name like "d:/foo" and "//server/share" is absolute
+ return ((isalpha(fname[0]) && fname[1] == ':'
+ && vim_ispathsep_nocolon(fname[2]))
+ || (vim_ispathsep_nocolon(fname[0]) && fname[0] == fname[1]));
+#else
+ // UNIX: This just checks if the file name starts with '/' or '~'.
return *fname == '/' || *fname == '~';
+#endif
}