0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 7.4.1516

Problem:    Cannot change file permissions.
Solution:   Add setfperm().
This commit is contained in:
Bram Moolenaar
2016-03-08 17:08:53 +01:00
parent 9fe885e49a
commit 8049253b96
5 changed files with 82 additions and 0 deletions

View File

@@ -735,6 +735,7 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv);
static void f_setbufvar(typval_T *argvars, typval_T *rettv);
static void f_setcharsearch(typval_T *argvars, typval_T *rettv);
static void f_setcmdpos(typval_T *argvars, typval_T *rettv);
static void f_setfperm(typval_T *argvars, typval_T *rettv);
static void f_setline(typval_T *argvars, typval_T *rettv);
static void f_setloclist(typval_T *argvars, typval_T *rettv);
static void f_setmatches(typval_T *argvars, typval_T *rettv);
@@ -8446,6 +8447,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, 3, f_setloclist},
{"setmatches", 1, 1, f_setmatches},
@@ -18421,6 +18423,42 @@ 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)
{
char_u *fname;
char_u modebuf[NUMBUFLEN];
char_u *mode_str;
int i;
int mask;
int mode = 0;
rettv->vval.v_number = 0;
fname = get_tv_string_chk(&argvars[0]);
if (fname == NULL)
return;
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;
}
mask = 1;
for (i = 8; i >= 0; --i)
{
if (mode_str[i] != '-')
mode |= mask;
mask = mask << 1;
}
rettv->vval.v_number = mch_setperm(fname, mode) == OK;
}
/*
* "setline()" function
*/