FileID: refactor path.c to use FileID

This commit is contained in:
Stefan Hoffmann
2014-05-27 20:36:23 +02:00
parent 7340f619d7
commit 21af178b14

View File

@@ -52,13 +52,13 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname)
char_u exp1[MAXPATHL]; char_u exp1[MAXPATHL];
char_u full1[MAXPATHL]; char_u full1[MAXPATHL];
char_u full2[MAXPATHL]; char_u full2[MAXPATHL];
uv_stat_t st1, st2; FileID file_id_1, file_id_2;
expand_env(s1, exp1, MAXPATHL); expand_env(s1, exp1, MAXPATHL);
int r1 = os_stat(exp1, &st1); bool id_ok_1 = os_get_file_id((char *)exp1, &file_id_1);
int r2 = os_stat(s2, &st2); bool id_ok_2 = os_get_file_id((char *)s2, &file_id_2);
if (r1 != OK && r2 != OK) { if (!id_ok_1 && !id_ok_2) {
// If os_stat() doesn't work, may compare the names. // If os_get_file_id() doesn't work, may compare the names.
if (checkname) { if (checkname) {
vim_FullName(exp1, full1, MAXPATHL, FALSE); vim_FullName(exp1, full1, MAXPATHL, FALSE);
vim_FullName(s2, full2, MAXPATHL, FALSE); vim_FullName(s2, full2, MAXPATHL, FALSE);
@@ -68,10 +68,10 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname)
} }
return kBothFilesMissing; return kBothFilesMissing;
} }
if (r1 != OK || r2 != OK) { if (!id_ok_1 || !id_ok_2) {
return kOneFileMissing; return kOneFileMissing;
} }
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) { if (os_file_id_equal(&file_id_1, &file_id_2)) {
return kEqualFiles; return kEqualFiles;
} }
return kDifferentFiles; return kDifferentFiles;