Add Windows support to path_is_absolute()

vim-patch:0
This commit is contained in:
Rui Abreu Ferreira 2015-04-13 12:48:35 +01:00
parent c9b29d3884
commit 22e9c51b0f

View File

@ -2186,9 +2186,15 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf,
/// Check if the given file is absolute. /// Check if the given file is absolute.
/// ///
/// This just checks if the file name starts with '/' or '~'.
/// @return `TRUE` if "fname" is absolute. /// @return `TRUE` if "fname" is absolute.
int path_is_absolute_path(const char_u *fname) 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 == '~'; return *fname == '/' || *fname == '~';
#endif
} }