mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
Move same_directory from misc2.c
This commit is contained in:

committed by
Thiago de Arruda

parent
e29e956348
commit
2a6df95fb5
21
src/path.c
21
src/path.c
@@ -1673,3 +1673,24 @@ int after_pathsep(char_u *b, char_u *p)
|
||||
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if file names "f1" and "f2" are in the same directory.
|
||||
* "f1" may be a short name, "f2" must be a full path.
|
||||
*/
|
||||
int same_directory(char_u *f1, char_u *f2)
|
||||
{
|
||||
char_u ffname[MAXPATHL];
|
||||
char_u *t1;
|
||||
char_u *t2;
|
||||
|
||||
/* safety check */
|
||||
if (f1 == NULL || f2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
(void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
|
||||
t1 = gettail_sep(ffname);
|
||||
t2 = gettail_sep(f2);
|
||||
return t1 - ffname == t2 - f2
|
||||
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user