mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
fileid: rename os_file_id_equal
This commit is contained in:
@@ -2441,7 +2441,7 @@ void buf_set_file_id(buf_T *buf)
|
|||||||
static bool buf_same_file_id(buf_T *buf, FileID *file_id)
|
static bool buf_same_file_id(buf_T *buf, FileID *file_id)
|
||||||
{
|
{
|
||||||
return buf->file_id_valid
|
return buf->file_id_valid
|
||||||
&& os_file_id_equal(&(buf->file_id), file_id);
|
&& os_fileid_equal(&(buf->file_id), file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -2423,7 +2423,7 @@ do_source (
|
|||||||
// Compare dev/ino when possible, it catches symbolic links.
|
// Compare dev/ino when possible, it catches symbolic links.
|
||||||
// Also compare file names, the inode may change when the file was edited.
|
// Also compare file names, the inode may change when the file was edited.
|
||||||
bool file_id_equal = file_id_ok && si->file_id_valid
|
bool file_id_equal = file_id_ok && si->file_id_valid
|
||||||
&& os_file_id_equal(&(si->file_id), &file_id);
|
&& os_fileid_equal(&(si->file_id), &file_id);
|
||||||
if (si->sn_name != NULL
|
if (si->sn_name != NULL
|
||||||
&& (file_id_equal || fnamecmp(si->sn_name, fname_exp) == 0)) {
|
&& (file_id_equal || fnamecmp(si->sn_name, fname_exp) == 0)) {
|
||||||
break;
|
break;
|
||||||
|
@@ -1106,7 +1106,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
|||||||
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->file_id_valid
|
|| (!url && vp->file_id_valid
|
||||||
&& os_file_id_equal(&(vp->file_id), &file_id))) {
|
&& os_fileid_equal(&(vp->file_id), &file_id))) {
|
||||||
/* 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 */
|
||||||
|
@@ -1181,7 +1181,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
|
|||||||
i = -1; /* can be set to the index of an empty item in csinfo */
|
i = -1; /* can be set to the index of an empty item in csinfo */
|
||||||
for (j = 0; j < csinfo_size; j++) {
|
for (j = 0; j < csinfo_size; j++) {
|
||||||
if (csinfo[j].fname != NULL
|
if (csinfo[j].fname != NULL
|
||||||
&& os_file_id_equal_file_info(&(csinfo[j].file_id), file_info)) {
|
&& os_fileid_equal_file_info(&(csinfo[j].file_id), file_info)) {
|
||||||
if (p_csverbose)
|
if (p_csverbose)
|
||||||
(void)EMSG(_("E568: duplicate cscope database not added"));
|
(void)EMSG(_("E568: duplicate cscope database not added"));
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -442,7 +442,7 @@ bool os_fileid(const char *path, FileID *file_id)
|
|||||||
/// @param file_id_1 Pointer to first `FileID`
|
/// @param file_id_1 Pointer to first `FileID`
|
||||||
/// @param file_id_2 Pointer to second `FileID`
|
/// @param file_id_2 Pointer to second `FileID`
|
||||||
/// @return `true` if the two `FileID`s represent te same file.
|
/// @return `true` if the two `FileID`s represent te same file.
|
||||||
bool os_file_id_equal(const FileID *file_id_1, const FileID *file_id_2)
|
bool os_fileid_equal(const FileID *file_id_1, const FileID *file_id_2)
|
||||||
{
|
{
|
||||||
return file_id_1->inode == file_id_2->inode
|
return file_id_1->inode == file_id_2->inode
|
||||||
&& file_id_1->device_id == file_id_2->device_id;
|
&& file_id_1->device_id == file_id_2->device_id;
|
||||||
@@ -453,7 +453,7 @@ bool os_file_id_equal(const FileID *file_id_1, const FileID *file_id_2)
|
|||||||
/// @param file_id Pointer to a `FileID`
|
/// @param file_id Pointer to a `FileID`
|
||||||
/// @param file_info Pointer to a `FileInfo`
|
/// @param file_info Pointer to a `FileInfo`
|
||||||
/// @return `true` if the `FileID` and the `FileInfo` represent te same file.
|
/// @return `true` if the `FileID` and the `FileInfo` represent te same file.
|
||||||
bool os_file_id_equal_file_info(const FileID *file_id,
|
bool os_fileid_equal_file_info(const FileID *file_id,
|
||||||
const FileInfo *file_info)
|
const FileInfo *file_info)
|
||||||
{
|
{
|
||||||
return file_id->inode == file_info->stat.st_ino
|
return file_id->inode == file_info->stat.st_ino
|
||||||
|
@@ -77,7 +77,7 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname)
|
|||||||
if (!id_ok_1 || !id_ok_2) {
|
if (!id_ok_1 || !id_ok_2) {
|
||||||
return kOneFileMissing;
|
return kOneFileMissing;
|
||||||
}
|
}
|
||||||
if (os_file_id_equal(&file_id_1, &file_id_2)) {
|
if (os_fileid_equal(&file_id_1, &file_id_2)) {
|
||||||
return kEqualFiles;
|
return kEqualFiles;
|
||||||
}
|
}
|
||||||
return kDifferentFiles;
|
return kDifferentFiles;
|
||||||
|
@@ -661,12 +661,12 @@ describe('fs function', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('os_file_id_equal', function()
|
describe('os_fileid_equal', function()
|
||||||
it('returns true if two FileIDs are equal', function()
|
it('returns true if two FileIDs are equal', function()
|
||||||
local file_id = file_id_new()
|
local file_id = file_id_new()
|
||||||
local path = 'unit-test-directory/test.file'
|
local path = 'unit-test-directory/test.file'
|
||||||
assert.is_true((fs.os_fileid(path, file_id)))
|
assert.is_true((fs.os_fileid(path, file_id)))
|
||||||
assert.is_true((fs.os_file_id_equal(file_id, file_id)))
|
assert.is_true((fs.os_fileid_equal(file_id, file_id)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns false if two FileIDs are not equal', function()
|
it('returns false if two FileIDs are not equal', function()
|
||||||
@@ -676,18 +676,18 @@ describe('fs function', function()
|
|||||||
local path_2 = 'unit-test-directory/test_2.file'
|
local path_2 = 'unit-test-directory/test_2.file'
|
||||||
assert.is_true((fs.os_fileid(path_1, file_id_1)))
|
assert.is_true((fs.os_fileid(path_1, file_id_1)))
|
||||||
assert.is_true((fs.os_fileid(path_2, file_id_2)))
|
assert.is_true((fs.os_fileid(path_2, file_id_2)))
|
||||||
assert.is_false((fs.os_file_id_equal(file_id_1, file_id_2)))
|
assert.is_false((fs.os_fileid_equal(file_id_1, file_id_2)))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('os_file_id_equal_file_info', function()
|
describe('os_fileid_equal_file_info', function()
|
||||||
it('returns true if file_id and file_info represent the same file', function()
|
it('returns true if file_id and file_info represent the same file', function()
|
||||||
local file_id = file_id_new()
|
local file_id = file_id_new()
|
||||||
local file_info = file_info_new()
|
local file_info = file_info_new()
|
||||||
local path = 'unit-test-directory/test.file'
|
local path = 'unit-test-directory/test.file'
|
||||||
assert.is_true((fs.os_fileid(path, file_id)))
|
assert.is_true((fs.os_fileid(path, file_id)))
|
||||||
assert.is_true((fs.os_fileinfo(path, file_info)))
|
assert.is_true((fs.os_fileinfo(path, file_info)))
|
||||||
assert.is_true((fs.os_file_id_equal_file_info(file_id, file_info)))
|
assert.is_true((fs.os_fileid_equal_file_info(file_id, file_info)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns false if file_id and file_info represent different files', function()
|
it('returns false if file_id and file_info represent different files', function()
|
||||||
@@ -697,7 +697,7 @@ describe('fs function', function()
|
|||||||
local path_2 = 'unit-test-directory/test_2.file'
|
local path_2 = 'unit-test-directory/test_2.file'
|
||||||
assert.is_true((fs.os_fileid(path_1, file_id)))
|
assert.is_true((fs.os_fileid(path_1, file_id)))
|
||||||
assert.is_true((fs.os_fileinfo(path_2, file_info)))
|
assert.is_true((fs.os_fileinfo(path_2, file_info)))
|
||||||
assert.is_false((fs.os_file_id_equal_file_info(file_id, file_info)))
|
assert.is_false((fs.os_fileid_equal_file_info(file_id, file_info)))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user