diff options
Diffstat (limited to 'src/filepath.c')
-rw-r--r-- | src/filepath.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/filepath.c b/src/filepath.c index 3bf8a2d..9f68d7c 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -292,7 +292,7 @@ shortpath_for_partial( modify_fname( char_u *src, // string with modifiers int tilde_file, // "~" is a file name, not $HOME - int *usedlen, // characters after src that are used + size_t *usedlen, // characters after src that are used char_u **fnamep, // file name so far char_u **bufp, // buffer for allocated file name or NULL int *fnamelen) // length of fnamep @@ -668,7 +668,7 @@ repeat: str = vim_strnsave(*fnamep, *fnamelen); if (sub != NULL && str != NULL) { - *usedlen = (int)(p + 1 - src); + *usedlen = p + 1 - src; s = do_string_sub(str, pat, sub, NULL, flags); if (s != NULL) { @@ -1038,7 +1038,7 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv) { char_u *fname; char_u *mods; - int usedlen = 0; + size_t usedlen = 0; int len = 0; char_u *fbuf = NULL; char_u buf[NUMBUFLEN]; @@ -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 /* @@ -2707,7 +2732,7 @@ home_replace( if (homedir_env != NULL && *homedir_env == '~') { - int usedlen = 0; + size_t usedlen = 0; int flen; char_u *fbuf = NULL; @@ -3170,7 +3195,7 @@ expand_wildcards_eval( char_u *eval_pat = NULL; char_u *exp_pat = *pat; char *ignored_msg; - int usedlen; + size_t usedlen; int is_cur_alt_file = *exp_pat == '%' || *exp_pat == '#'; int star_follows = FALSE; |