mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 01:38:16 +00:00
FileID: refactor os_unix.c to use FileID
This commit is contained in:
@@ -381,12 +381,12 @@ char_u *name,
|
|||||||
int len /* buffer size, only used when name gets longer */
|
int len /* buffer size, only used when name gets longer */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct stat st;
|
|
||||||
char_u *slash, *tail;
|
char_u *slash, *tail;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
|
|
||||||
if (lstat((char *)name, &st) >= 0) {
|
FileInfo file_info;
|
||||||
|
if (os_get_file_info_link((char *)name, &file_info)) {
|
||||||
/* Open the directory where the file is located. */
|
/* Open the directory where the file is located. */
|
||||||
slash = vim_strrchr(name, '/');
|
slash = vim_strrchr(name, '/');
|
||||||
if (slash == NULL) {
|
if (slash == NULL) {
|
||||||
@@ -406,15 +406,14 @@ int len /* buffer size, only used when name gets longer */
|
|||||||
if (STRICMP(tail, dp->d_name) == 0
|
if (STRICMP(tail, dp->d_name) == 0
|
||||||
&& STRLEN(tail) == STRLEN(dp->d_name)) {
|
&& STRLEN(tail) == STRLEN(dp->d_name)) {
|
||||||
char_u newname[MAXPATHL + 1];
|
char_u newname[MAXPATHL + 1];
|
||||||
struct stat st2;
|
|
||||||
|
|
||||||
/* Verify the inode is equal. */
|
/* Verify the inode is equal. */
|
||||||
STRLCPY(newname, name, MAXPATHL + 1);
|
STRLCPY(newname, name, MAXPATHL + 1);
|
||||||
STRLCPY(newname + (tail - name), dp->d_name,
|
STRLCPY(newname + (tail - name), dp->d_name,
|
||||||
MAXPATHL - (tail - name) + 1);
|
MAXPATHL - (tail - name) + 1);
|
||||||
if (lstat((char *)newname, &st2) >= 0
|
FileInfo file_info_new;
|
||||||
&& st.st_ino == st2.st_ino
|
if (os_get_file_info_link((char *)newname, &file_info_new)
|
||||||
&& st.st_dev == st2.st_dev) {
|
&& os_file_info_id_equal(&file_info, &file_info_new)) {
|
||||||
STRCPY(tail, dp->d_name);
|
STRCPY(tail, dp->d_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user