mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
fileinfo: rename os_file_info_id_equal
This commit is contained in:
@@ -2714,7 +2714,7 @@ buf_write (
|
|||||||
*/
|
*/
|
||||||
if (os_fileinfo_hardlinks(&file_info_old) > 1
|
if (os_fileinfo_hardlinks(&file_info_old) > 1
|
||||||
|| !os_fileinfo_link((char *)fname, &file_info)
|
|| !os_fileinfo_link((char *)fname, &file_info)
|
||||||
|| !os_file_info_id_equal(&file_info, &file_info_old)) {
|
|| !os_fileinfo_id_equal(&file_info, &file_info_old)) {
|
||||||
backup_copy = TRUE;
|
backup_copy = TRUE;
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
@@ -2764,7 +2764,7 @@ buf_write (
|
|||||||
/* Symlinks. */
|
/* Symlinks. */
|
||||||
if ((bkc_flags & BKC_BREAKSYMLINK)
|
if ((bkc_flags & BKC_BREAKSYMLINK)
|
||||||
&& file_info_link_ok
|
&& file_info_link_ok
|
||||||
&& !os_file_info_id_equal(&file_info, &file_info_old)) {
|
&& !os_fileinfo_id_equal(&file_info, &file_info_old)) {
|
||||||
backup_copy = FALSE;
|
backup_copy = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2772,7 +2772,7 @@ buf_write (
|
|||||||
if ((bkc_flags & BKC_BREAKHARDLINK)
|
if ((bkc_flags & BKC_BREAKHARDLINK)
|
||||||
&& os_fileinfo_hardlinks(&file_info_old) > 1
|
&& os_fileinfo_hardlinks(&file_info_old) > 1
|
||||||
&& (!file_info_link_ok
|
&& (!file_info_link_ok
|
||||||
|| os_file_info_id_equal(&file_info, &file_info_old))) {
|
|| os_fileinfo_id_equal(&file_info, &file_info_old))) {
|
||||||
backup_copy = FALSE;
|
backup_copy = FALSE;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@@ -2844,7 +2844,7 @@ buf_write (
|
|||||||
* link). If we don't check here, we either ruin the file when
|
* link). If we don't check here, we either ruin the file when
|
||||||
* copying or erase it after writing.
|
* copying or erase it after writing.
|
||||||
*/
|
*/
|
||||||
if (os_file_info_id_equal(&file_info_new, &file_info_old)) {
|
if (os_fileinfo_id_equal(&file_info_new, &file_info_old)) {
|
||||||
free(backup);
|
free(backup);
|
||||||
backup = NULL; /* no backup file to delete */
|
backup = NULL; /* no backup file to delete */
|
||||||
}
|
}
|
||||||
@@ -3203,7 +3203,7 @@ nobackup:
|
|||||||
/* Don't delete the file when it's a hard or symbolic link. */
|
/* Don't delete the file when it's a hard or symbolic link. */
|
||||||
if ((!newfile && os_fileinfo_hardlinks(&file_info) > 1)
|
if ((!newfile && os_fileinfo_hardlinks(&file_info) > 1)
|
||||||
|| (os_fileinfo_link((char *)fname, &file_info)
|
|| (os_fileinfo_link((char *)fname, &file_info)
|
||||||
&& !os_file_info_id_equal(&file_info, &file_info_old))) {
|
&& !os_fileinfo_id_equal(&file_info, &file_info_old))) {
|
||||||
errmsg = (char_u *)_("E166: Can't open linked file for writing");
|
errmsg = (char_u *)_("E166: Can't open linked file for writing");
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -4545,7 +4545,7 @@ int vim_rename(char_u *from, char_u *to)
|
|||||||
// filesystem. In that case go through a temp file name.
|
// filesystem. In that case go through a temp file name.
|
||||||
FileInfo to_info;
|
FileInfo to_info;
|
||||||
if (os_fileinfo((char *)to, &to_info)
|
if (os_fileinfo((char *)to, &to_info)
|
||||||
&& os_file_info_id_equal(&from_info, &to_info)) {
|
&& os_fileinfo_id_equal(&from_info, &to_info)) {
|
||||||
use_tmp_file = true;
|
use_tmp_file = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -367,7 +367,7 @@ bool os_fileinfo_fd(int file_descriptor, FileInfo *file_info)
|
|||||||
/// Compare the inodes of two FileInfos
|
/// Compare the inodes of two FileInfos
|
||||||
///
|
///
|
||||||
/// @return `true` if the two FileInfos represent the same file.
|
/// @return `true` if the two FileInfos represent the same file.
|
||||||
bool os_file_info_id_equal(const FileInfo *file_info_1,
|
bool os_fileinfo_id_equal(const FileInfo *file_info_1,
|
||||||
const FileInfo *file_info_2)
|
const FileInfo *file_info_2)
|
||||||
{
|
{
|
||||||
return file_info_1->stat.st_ino == file_info_2->stat.st_ino
|
return file_info_1->stat.st_ino == file_info_2->stat.st_ino
|
||||||
|
@@ -355,7 +355,7 @@ int len /* buffer size, only used when name gets longer */
|
|||||||
MAXPATHL - (tail - name) + 1);
|
MAXPATHL - (tail - name) + 1);
|
||||||
FileInfo file_info_new;
|
FileInfo file_info_new;
|
||||||
if (os_fileinfo_link((char *)newname, &file_info_new)
|
if (os_fileinfo_link((char *)newname, &file_info_new)
|
||||||
&& os_file_info_id_equal(&file_info, &file_info_new)) {
|
&& os_fileinfo_id_equal(&file_info, &file_info_new)) {
|
||||||
STRCPY(tail, dp->d_name);
|
STRCPY(tail, dp->d_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1351,7 +1351,7 @@ void simplify_filename(char_u *filename)
|
|||||||
*p = saved_char;
|
*p = saved_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!os_file_info_id_equal(&file_info, &new_file_info)) {
|
if (!os_fileinfo_id_equal(&file_info, &new_file_info)) {
|
||||||
do_strip = FALSE;
|
do_strip = FALSE;
|
||||||
/* We don't disable stripping of later
|
/* We don't disable stripping of later
|
||||||
* components since the unstripped path name is
|
* components since the unstripped path name is
|
||||||
|
@@ -545,7 +545,7 @@ describe('fs function', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('os_file_info_id_equal', function()
|
describe('os_fileinfo_id_equal', function()
|
||||||
it('returns false if file infos represent different files', function()
|
it('returns false if file infos represent different files', function()
|
||||||
local file_info_1 = file_info_new()
|
local file_info_1 = file_info_new()
|
||||||
local file_info_2 = file_info_new()
|
local file_info_2 = file_info_new()
|
||||||
@@ -553,7 +553,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_fileinfo(path_1, file_info_1)))
|
assert.is_true((fs.os_fileinfo(path_1, file_info_1)))
|
||||||
assert.is_true((fs.os_fileinfo(path_2, file_info_2)))
|
assert.is_true((fs.os_fileinfo(path_2, file_info_2)))
|
||||||
assert.is_false((fs.os_file_info_id_equal(file_info_1, file_info_2)))
|
assert.is_false((fs.os_fileinfo_id_equal(file_info_1, file_info_2)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns true if file infos represent the same file', function()
|
it('returns true if file infos represent the same file', function()
|
||||||
@@ -562,7 +562,7 @@ describe('fs function', function()
|
|||||||
local path = 'unit-test-directory/test.file'
|
local path = 'unit-test-directory/test.file'
|
||||||
assert.is_true((fs.os_fileinfo(path, file_info_1)))
|
assert.is_true((fs.os_fileinfo(path, file_info_1)))
|
||||||
assert.is_true((fs.os_fileinfo(path, file_info_2)))
|
assert.is_true((fs.os_fileinfo(path, file_info_2)))
|
||||||
assert.is_true((fs.os_file_info_id_equal(file_info_1, file_info_2)))
|
assert.is_true((fs.os_fileinfo_id_equal(file_info_1, file_info_2)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns true if file infos represent the same file (symlink)', function()
|
it('returns true if file infos represent the same file (symlink)', function()
|
||||||
@@ -572,7 +572,7 @@ describe('fs function', function()
|
|||||||
local path_2 = 'unit-test-directory/test_link.file'
|
local path_2 = 'unit-test-directory/test_link.file'
|
||||||
assert.is_true((fs.os_fileinfo(path_1, file_info_1)))
|
assert.is_true((fs.os_fileinfo(path_1, file_info_1)))
|
||||||
assert.is_true((fs.os_fileinfo(path_2, file_info_2)))
|
assert.is_true((fs.os_fileinfo(path_2, file_info_2)))
|
||||||
assert.is_true((fs.os_file_info_id_equal(file_info_1, file_info_2)))
|
assert.is_true((fs.os_fileinfo_id_equal(file_info_1, file_info_2)))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user