mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
vim-patch:7.4.1516
Problem: Cannot change file permissions.
Solution: Add setfperm().
8049253b96
This commit is contained in:
@@ -6877,6 +6877,7 @@ static struct fst {
|
||||
{ "setbufvar", 3, 3, f_setbufvar },
|
||||
{ "setcharsearch", 1, 1, f_setcharsearch },
|
||||
{ "setcmdpos", 1, 1, f_setcmdpos },
|
||||
{ "setfperm", 2, 2, f_setfperm },
|
||||
{ "setline", 2, 2, f_setline },
|
||||
{ "setloclist", 2, 4, f_setloclist },
|
||||
{ "setmatches", 1, 1, f_setmatches },
|
||||
@@ -14446,6 +14447,38 @@ static void f_setcmdpos(typval_T *argvars, typval_T *rettv)
|
||||
rettv->vval.v_number = set_cmdline_pos(pos);
|
||||
}
|
||||
|
||||
|
||||
/// "setfperm({fname}, {mode})" function
|
||||
static void f_setfperm(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
rettv->vval.v_number = 0;
|
||||
|
||||
char_u *fname = get_tv_string_chk(&argvars[0]);
|
||||
if (fname == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
char_u modebuf[NUMBUFLEN];
|
||||
char_u *mode_str = get_tv_string_buf_chk(&argvars[1], modebuf);
|
||||
if (mode_str == NULL) {
|
||||
return;
|
||||
}
|
||||
if (STRLEN(mode_str) != 9) {
|
||||
EMSG2(_(e_invarg2), mode_str);
|
||||
return;
|
||||
}
|
||||
|
||||
int mask = 1;
|
||||
int mode = 0;
|
||||
for (int i = 8; i >= 0; i--) {
|
||||
if (mode_str[i] != '-') {
|
||||
mode |= mask;
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
rettv->vval.v_number = os_setperm(fname, mode) == OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* "setline()" function
|
||||
*/
|
||||
|
@@ -168,7 +168,7 @@ static int included_patches[] = {
|
||||
// 1519 NA
|
||||
// 1518 NA
|
||||
// 1517 NA
|
||||
// 1516,
|
||||
1516,
|
||||
// 1515 NA
|
||||
// 1514 NA
|
||||
1513,
|
||||
|
Reference in New Issue
Block a user