mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
FileID: refactor file_search.c to use FileID
This commit is contained in:
@@ -61,6 +61,7 @@
|
|||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
|
#include "nvim/os/fs_defs.h"
|
||||||
|
|
||||||
static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
|
static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
|
||||||
|
|
||||||
@@ -108,12 +109,9 @@ typedef struct ff_visited {
|
|||||||
* different. So we have to save it.
|
* different. So we have to save it.
|
||||||
*/
|
*/
|
||||||
char_u *ffv_wc_path;
|
char_u *ffv_wc_path;
|
||||||
/* for unix use inode etc for comparison (needed because of links), else
|
// use FileID for comparison (needed because of links), else use filename.
|
||||||
* use filename.
|
bool file_id_valid;
|
||||||
*/
|
FileID file_id;
|
||||||
int ffv_dev_valid; /* ffv_dev and ffv_ino were set */
|
|
||||||
uint64_t ffv_dev; /* device number */
|
|
||||||
uint64_t ffv_ino; /* inode number */
|
|
||||||
/* The memory for this struct is allocated according to the length of
|
/* The memory for this struct is allocated according to the length of
|
||||||
* ffv_fname.
|
* ffv_fname.
|
||||||
*/
|
*/
|
||||||
@@ -1088,15 +1086,15 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
|||||||
ff_visited_T *vp;
|
ff_visited_T *vp;
|
||||||
bool url = false;
|
bool url = false;
|
||||||
|
|
||||||
FileInfo file_info;
|
FileID file_id;
|
||||||
// For a URL we only compare the name, otherwise we compare the
|
// For an URL we only compare the name, otherwise we compare the
|
||||||
// device/inode.
|
// device/inode.
|
||||||
if (path_with_url(fname)) {
|
if (path_with_url(fname)) {
|
||||||
STRLCPY(ff_expand_buffer, fname, MAXPATHL);
|
STRLCPY(ff_expand_buffer, fname, MAXPATHL);
|
||||||
url = true;
|
url = true;
|
||||||
} else {
|
} else {
|
||||||
ff_expand_buffer[0] = NUL;
|
ff_expand_buffer[0] = NUL;
|
||||||
if (!os_get_file_info((char *)fname, &file_info)) {
|
if (!os_get_file_id((char *)fname, &file_id)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,9 +1102,8 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
|||||||
/* check against list of already visited files */
|
/* check against list of already visited files */
|
||||||
for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) {
|
for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) {
|
||||||
if ((url && fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0)
|
if ((url && fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0)
|
||||||
|| (!url && vp->ffv_dev_valid
|
|| (!url && vp->file_id_valid
|
||||||
&& vp->ffv_dev == file_info.stat.st_dev
|
&& os_file_id_equal(&(vp->file_id), &file_id))) {
|
||||||
&& vp->ffv_ino == file_info.stat.st_ino)) {
|
|
||||||
/* are the wildcard parts equal */
|
/* are the wildcard parts equal */
|
||||||
if (ff_wc_equal(vp->ffv_wc_path, wc_path) == TRUE)
|
if (ff_wc_equal(vp->ffv_wc_path, wc_path) == TRUE)
|
||||||
/* already visited */
|
/* already visited */
|
||||||
@@ -1120,12 +1117,11 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
|||||||
vp = xmalloc(sizeof(ff_visited_T) + STRLEN(ff_expand_buffer));
|
vp = xmalloc(sizeof(ff_visited_T) + STRLEN(ff_expand_buffer));
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
vp->ffv_dev_valid = TRUE;
|
vp->file_id_valid = true;
|
||||||
vp->ffv_ino = file_info.stat.st_ino;
|
vp->file_id = file_id;
|
||||||
vp->ffv_dev = file_info.stat.st_dev;
|
|
||||||
vp->ffv_fname[0] = NUL;
|
vp->ffv_fname[0] = NUL;
|
||||||
} else {
|
} else {
|
||||||
vp->ffv_dev_valid = FALSE;
|
vp->file_id_valid = false;
|
||||||
STRCPY(vp->ffv_fname, ff_expand_buffer);
|
STRCPY(vp->ffv_fname, ff_expand_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user