mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge #5198 from equalsraf/windows-path-is-absolute
Windows: path_is_absolute()
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user