0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.1.0465: missing filecopy() function

Problem:  missing filecopy() function
Solution: implement filecopy() Vim script function
          (Shougo Matsushita)

closes: #12346

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Shougo Matsushita
2024-06-03 22:59:27 +02:00
committed by Christian Brabandt
parent 0a0830624a
commit 60c8743ab6
14 changed files with 198 additions and 31 deletions

View File

@@ -2649,6 +2649,31 @@ f_browsedir(typval_T *argvars UNUSED, typval_T *rettv)
rettv->v_type = VAR_STRING;
}
/*
* "filecopy()" function
*/
void
f_filecopy(typval_T *argvars, typval_T *rettv)
{
char_u *from;
stat_T st;
rettv->vval.v_number = FALSE;
if (check_restricted() || check_secure()
|| check_for_string_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL)
return;
from = tv_get_string(&argvars[0]);
if (mch_lstat((char *)from, &st) >= 0
&& (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
rettv->vval.v_number = vim_copyfile(
tv_get_string(&argvars[0]),
tv_get_string(&argvars[1])) == OK ? TRUE : FALSE;
}
#endif // FEAT_EVAL
/*