mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
refactor(fileio.c): remove HAVE_ACL ifdefs
This commit is contained in:
@@ -2628,9 +2628,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
|
|||||||
(double)file_info_old->stat.st_atim.tv_sec,
|
(double)file_info_old->stat.st_atim.tv_sec,
|
||||||
(double)file_info_old->stat.st_mtim.tv_sec);
|
(double)file_info_old->stat.st_mtim.tv_sec);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_set_acl(*backupp, acl);
|
os_set_acl(*backupp, acl);
|
||||||
#endif
|
|
||||||
*err = set_err(NULL);
|
*err = set_err(NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2908,12 +2906,10 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ACL
|
|
||||||
// For systems that support ACL: get the ACL from the original file.
|
// For systems that support ACL: get the ACL from the original file.
|
||||||
if (!newfile) {
|
if (!newfile) {
|
||||||
acl = os_get_acl(fname);
|
acl = os_get_acl(fname);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// If 'backupskip' is not empty, don't make a backup for some files.
|
// If 'backupskip' is not empty, don't make a backup for some files.
|
||||||
bool dobackup = (p_wb || p_bk || *p_pm != NUL);
|
bool dobackup = (p_wb || p_bk || *p_pm != NUL);
|
||||||
@@ -3371,13 +3367,11 @@ restore_backup:
|
|||||||
if (perm >= 0) { // Set perm. of new file same as old file.
|
if (perm >= 0) { // Set perm. of new file same as old file.
|
||||||
(void)os_setperm((const char *)wfname, (int)perm);
|
(void)os_setperm((const char *)wfname, (int)perm);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_ACL
|
|
||||||
// Probably need to set the ACL before changing the user (can't set the
|
// Probably need to set the ACL before changing the user (can't set the
|
||||||
// ACL on a file the user doesn't own).
|
// ACL on a file the user doesn't own).
|
||||||
if (!backup_copy) {
|
if (!backup_copy) {
|
||||||
os_set_acl(wfname, acl);
|
os_set_acl(wfname, acl);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (wfname != fname) {
|
if (wfname != fname) {
|
||||||
// The file was written to a temp file, now it needs to be converted
|
// The file was written to a temp file, now it needs to be converted
|
||||||
@@ -3588,9 +3582,7 @@ nofail:
|
|||||||
iconv_close(write_info.bw_iconv_fd);
|
iconv_close(write_info.bw_iconv_fd);
|
||||||
write_info.bw_iconv_fd = (iconv_t)-1;
|
write_info.bw_iconv_fd = (iconv_t)-1;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (err.msg != NULL) {
|
if (err.msg != NULL) {
|
||||||
// - 100 to save some space for further error message
|
// - 100 to save some space for further error message
|
||||||
@@ -4577,15 +4569,11 @@ int vim_rename(const char *from, const char *to)
|
|||||||
|
|
||||||
// Rename() failed, try copying the file.
|
// Rename() failed, try copying the file.
|
||||||
long perm = os_getperm(from);
|
long perm = os_getperm(from);
|
||||||
#ifdef HAVE_ACL
|
|
||||||
// For systems that support ACL: get the ACL from the original file.
|
// For systems that support ACL: get the ACL from the original file.
|
||||||
vim_acl_T acl = os_get_acl(from);
|
vim_acl_T acl = os_get_acl(from);
|
||||||
#endif
|
|
||||||
int fd_in = os_open((char *)from, O_RDONLY, 0);
|
int fd_in = os_open((char *)from, O_RDONLY, 0);
|
||||||
if (fd_in < 0) {
|
if (fd_in < 0) {
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4593,9 +4581,7 @@ int vim_rename(const char *from, const char *to)
|
|||||||
int fd_out = os_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, (int)perm);
|
int fd_out = os_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, (int)perm);
|
||||||
if (fd_out < 0) {
|
if (fd_out < 0) {
|
||||||
close(fd_in);
|
close(fd_in);
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4605,9 +4591,7 @@ int vim_rename(const char *from, const char *to)
|
|||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
close(fd_out);
|
close(fd_out);
|
||||||
close(fd_in);
|
close(fd_in);
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4631,10 +4615,8 @@ int vim_rename(const char *from, const char *to)
|
|||||||
#ifndef UNIX // For Unix os_open() already set the permission.
|
#ifndef UNIX // For Unix os_open() already set the permission.
|
||||||
os_setperm(to, perm);
|
os_setperm(to, perm);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ACL
|
|
||||||
os_set_acl(to, acl);
|
os_set_acl(to, acl);
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
#endif
|
|
||||||
if (errmsg != NULL) {
|
if (errmsg != NULL) {
|
||||||
semsg(errmsg, to);
|
semsg(errmsg, to);
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -788,6 +788,7 @@ int os_setperm(const char *const name, int perm)
|
|||||||
# ifdef HAVE_SYS_ACCESS_H
|
# ifdef HAVE_SYS_ACCESS_H
|
||||||
# include <sys/access.h>
|
# include <sys/access.h>
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Return a pointer to the ACL of file "fname" in allocated memory.
|
// Return a pointer to the ACL of file "fname" in allocated memory.
|
||||||
// Return NULL if the ACL is not available for whatever reason.
|
// Return NULL if the ACL is not available for whatever reason.
|
||||||
@@ -811,7 +812,6 @@ void os_free_acl(vim_acl_T aclent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
/// Checks if the current user owns a file.
|
/// Checks if the current user owns a file.
|
||||||
|
@@ -1339,14 +1339,12 @@ write_error:
|
|||||||
semsg(_("E829: write error in undo file: %s"), file_name);
|
semsg(_("E829: write error in undo file: %s"), file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ACL
|
|
||||||
if (buf->b_ffname != NULL) {
|
if (buf->b_ffname != NULL) {
|
||||||
// For systems that support ACL: get the ACL from the original file.
|
// For systems that support ACL: get the ACL from the original file.
|
||||||
vim_acl_T acl = os_get_acl(buf->b_ffname);
|
vim_acl_T acl = os_get_acl(buf->b_ffname);
|
||||||
os_set_acl(file_name, acl);
|
os_set_acl(file_name, acl);
|
||||||
os_free_acl(acl);
|
os_free_acl(acl);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
theend:
|
theend:
|
||||||
if (file_name != name) {
|
if (file_name != name) {
|
||||||
|
Reference in New Issue
Block a user