From 22e9c51b0f24bd8717d9793a35d741adb9ade797 Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Mon, 13 Apr 2015 12:48:35 +0100 Subject: Add Windows support to path_is_absolute() vim-patch:0 --- src/nvim/path.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/path.c b/src/nvim/path.c index c20dffa9b1..4a47a70799 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -2186,9 +2186,15 @@ 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 ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\')) + || (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\'))); +#else + // UNIX: This just checks if the file name starts with '/' or '~'. return *fname == '/' || *fname == '~'; +#endif } -- cgit