aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorStefan Hoffmann <stefan991@gmail.com>2014-05-27 19:38:30 +0200
committerStefan Hoffmann <stefan991@gmail.com>2014-06-27 13:59:28 +0200
commitfc2a668c7c6582daae1c20a6198d9bf0af41b989 (patch)
tree14f0dcfa19dd45a4044de0799077740edc84bdab /src/nvim/ex_cmds2.c
parenta294a0e1c598179409490991de071bd4957ae2e7 (diff)
downloadrneovim-fc2a668c7c6582daae1c20a6198d9bf0af41b989.tar.gz
rneovim-fc2a668c7c6582daae1c20a6198d9bf0af41b989.tar.bz2
rneovim-fc2a668c7c6582daae1c20a6198d9bf0af41b989.zip
FileID: refactor ex_cmds2.c to use `FileID`
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 17c0f3bf3e..93822ebcfe 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -45,6 +45,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/fs_defs.h"
/* Growarray to store info about already sourced scripts.
@@ -52,9 +53,8 @@
* script when going through the list. */
typedef struct scriptitem_S {
char_u *sn_name;
- int sn_dev_valid;
- uint64_t sn_dev;
- uint64_t sn_ino;
+ bool file_id_valid;
+ FileID file_id;
int sn_prof_on; /* TRUE when script is/was profiled */
int sn_pr_force; /* forceit: profile functions in this script */
proftime_T sn_pr_child; /* time set when going into first child */
@@ -2559,15 +2559,14 @@ do_source (
* If it's new, generate a new SID.
*/
save_current_SID = current_SID;
- FileInfo file_info;
- bool file_info_ok = os_get_file_info((char *)fname_exp, &file_info);
+ FileID file_id;
+ bool file_id_ok = os_get_file_id((char *)fname_exp, &file_id);
for (current_SID = script_items.ga_len; current_SID > 0; --current_SID) {
si = &SCRIPT_ITEM(current_SID);
// Compare dev/ino when possible, it catches symbolic links.
// Also compare file names, the inode may change when the file was edited.
- bool file_id_equal = file_info_ok && si->sn_dev_valid
- && si->sn_dev == file_info.stat.st_dev
- && si->sn_ino == file_info.stat.st_ino;
+ bool file_id_equal = file_id_ok && si->file_id_valid
+ && os_file_id_equal(&(si->file_id), &file_id);
if (si->sn_name != NULL
&& (file_id_equal || fnamecmp(si->sn_name, fname_exp) == 0)) {
break;
@@ -2584,12 +2583,11 @@ do_source (
si = &SCRIPT_ITEM(current_SID);
si->sn_name = fname_exp;
fname_exp = NULL;
- if (file_info_ok) {
- si->sn_dev_valid = TRUE;
- si->sn_dev = file_info.stat.st_dev;
- si->sn_ino = file_info.stat.st_ino;
+ if (file_id_ok) {
+ si->file_id_valid = true;
+ si->file_id = file_id;
} else {
- si->sn_dev_valid = FALSE;
+ si->file_id_valid = false;
}
/* Allocate the local script variables to use for this script. */