mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 12:58:16 +00:00
fileid: rename os_get_file_id
This commit is contained in:
@@ -1314,7 +1314,7 @@ buflist_new (
|
||||
* for hard links. */
|
||||
FileID file_id;
|
||||
bool file_id_valid = (sfname != NULL &&
|
||||
os_get_file_id((char *)sfname, &file_id));
|
||||
os_fileid((char *)sfname, &file_id));
|
||||
if (ffname != NULL && !(flags & BLN_DUMMY)
|
||||
&& (buf = buflist_findname_file_id(ffname, &file_id,
|
||||
file_id_valid)) != NULL) {
|
||||
@@ -1671,7 +1671,7 @@ buf_T *buflist_findname_exp(char_u *fname)
|
||||
buf_T *buflist_findname(char_u *ffname)
|
||||
{
|
||||
FileID file_id;
|
||||
bool file_id_valid = os_get_file_id((char *)ffname, &file_id);
|
||||
bool file_id_valid = os_fileid((char *)ffname, &file_id);
|
||||
return buflist_findname_file_id(ffname, &file_id, file_id_valid);
|
||||
}
|
||||
|
||||
@@ -2221,7 +2221,7 @@ setfname (
|
||||
* - if the buffer is loaded, fail
|
||||
* - if the buffer is not loaded, delete it from the list
|
||||
*/
|
||||
file_id_valid = os_get_file_id((char *)ffname, &file_id);
|
||||
file_id_valid = os_fileid((char *)ffname, &file_id);
|
||||
if (!(buf->b_flags & BF_DUMMY)) {
|
||||
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
|
||||
}
|
||||
@@ -2399,7 +2399,7 @@ static int otherfile_buf(buf_T *buf, char_u *ffname,
|
||||
/* If no struct stat given, get it now */
|
||||
if (file_id_p == NULL) {
|
||||
file_id_p = &file_id;
|
||||
file_id_valid = os_get_file_id((char *)ffname, file_id_p);
|
||||
file_id_valid = os_fileid((char *)ffname, file_id_p);
|
||||
}
|
||||
if (!file_id_valid) {
|
||||
// file_id not valid, assume files are different.
|
||||
@@ -2429,7 +2429,7 @@ void buf_set_file_id(buf_T *buf)
|
||||
{
|
||||
FileID file_id;
|
||||
if (buf->b_fname != NULL
|
||||
&& os_get_file_id((char *)buf->b_fname, &file_id)) {
|
||||
&& os_fileid((char *)buf->b_fname, &file_id)) {
|
||||
buf->file_id_valid = true;
|
||||
buf->file_id = file_id;
|
||||
} else {
|
||||
|
@@ -2417,7 +2417,7 @@ do_source (
|
||||
*/
|
||||
save_current_SID = current_SID;
|
||||
FileID file_id;
|
||||
bool file_id_ok = os_get_file_id((char *)fname_exp, &file_id);
|
||||
bool file_id_ok = os_fileid((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.
|
||||
|
@@ -1097,7 +1097,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
||||
url = true;
|
||||
} else {
|
||||
ff_expand_buffer[0] = NUL;
|
||||
if (!os_get_file_id((char *)fname, &file_id)) {
|
||||
if (!os_fileid((char *)fname, &file_id)) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
@@ -426,7 +426,7 @@ uint64_t os_fileinfo_blocksize(const FileInfo *file_info)
|
||||
/// @param path Path to the file.
|
||||
/// @param[out] file_info Pointer to a `FileID` to fill in.
|
||||
/// @return `true` on sucess, `false` for failure.
|
||||
bool os_get_file_id(const char *path, FileID *file_id)
|
||||
bool os_fileid(const char *path, FileID *file_id)
|
||||
{
|
||||
uv_stat_t statbuf;
|
||||
if (os_stat(path, &statbuf)) {
|
||||
|
@@ -61,10 +61,10 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname)
|
||||
FileID file_id_1, file_id_2;
|
||||
|
||||
expand_env(s1, exp1, MAXPATHL);
|
||||
bool id_ok_1 = os_get_file_id((char *)exp1, &file_id_1);
|
||||
bool id_ok_2 = os_get_file_id((char *)s2, &file_id_2);
|
||||
bool id_ok_1 = os_fileid((char *)exp1, &file_id_1);
|
||||
bool id_ok_2 = os_fileid((char *)s2, &file_id_2);
|
||||
if (!id_ok_1 && !id_ok_2) {
|
||||
// If os_get_file_id() doesn't work, may compare the names.
|
||||
// If os_fileid() doesn't work, may compare the names.
|
||||
if (checkname) {
|
||||
vim_FullName(exp1, full1, MAXPATHL, FALSE);
|
||||
vim_FullName(s2, full2, MAXPATHL, FALSE);
|
||||
|
@@ -646,16 +646,16 @@ describe('fs function', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('os_get_file_id', function()
|
||||
describe('os_fileid', function()
|
||||
it('returns false if given an non-existing file', function()
|
||||
local file_id = file_id_new()
|
||||
assert.is_false((fs.os_get_file_id('/non-existent', file_id)))
|
||||
assert.is_false((fs.os_fileid('/non-existent', file_id)))
|
||||
end)
|
||||
|
||||
it('returns true if given an existing file and fills file_id', function()
|
||||
local file_id = file_id_new()
|
||||
local path = 'unit-test-directory/test.file'
|
||||
assert.is_true((fs.os_get_file_id(path, file_id)))
|
||||
assert.is_true((fs.os_fileid(path, file_id)))
|
||||
assert.is_true(0 < file_id[0].inode)
|
||||
assert.is_true(0 < file_id[0].device_id)
|
||||
end)
|
||||
@@ -665,7 +665,7 @@ describe('fs function', function()
|
||||
it('returns true if two FileIDs are equal', function()
|
||||
local file_id = file_id_new()
|
||||
local path = 'unit-test-directory/test.file'
|
||||
assert.is_true((fs.os_get_file_id(path, file_id)))
|
||||
assert.is_true((fs.os_fileid(path, file_id)))
|
||||
assert.is_true((fs.os_file_id_equal(file_id, file_id)))
|
||||
end)
|
||||
|
||||
@@ -674,8 +674,8 @@ describe('fs function', function()
|
||||
local file_id_2 = file_id_new()
|
||||
local path_1 = 'unit-test-directory/test.file'
|
||||
local path_2 = 'unit-test-directory/test_2.file'
|
||||
assert.is_true((fs.os_get_file_id(path_1, file_id_1)))
|
||||
assert.is_true((fs.os_get_file_id(path_2, file_id_2)))
|
||||
assert.is_true((fs.os_fileid(path_1, file_id_1)))
|
||||
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)))
|
||||
end)
|
||||
end)
|
||||
@@ -685,7 +685,7 @@ describe('fs function', function()
|
||||
local file_id = file_id_new()
|
||||
local file_info = file_info_new()
|
||||
local path = 'unit-test-directory/test.file'
|
||||
assert.is_true((fs.os_get_file_id(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_file_id_equal_file_info(file_id, file_info)))
|
||||
end)
|
||||
@@ -695,7 +695,7 @@ describe('fs function', function()
|
||||
local file_info = file_info_new()
|
||||
local path_1 = 'unit-test-directory/test.file'
|
||||
local path_2 = 'unit-test-directory/test_2.file'
|
||||
assert.is_true((fs.os_get_file_id(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_false((fs.os_file_id_equal_file_info(file_id, file_info)))
|
||||
end)
|
||||
|
Reference in New Issue
Block a user