fs.c: implement os_file_is_readable()

Use access() because:

- We already use it for os_file_is_writable()
- Vim's old check_file_readonly() ends up using access() after all.
This commit is contained in:
Justin M. Keyes
2015-08-11 16:34:45 -04:00
parent 616b787d12
commit 3ce1b4015f
2 changed files with 14 additions and 20 deletions

View File

@@ -8562,27 +8562,12 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv)
}
}
/*
* "filereadable()" function
*/
/// "filereadable()" function
static void f_filereadable(typval_T *argvars, typval_T *rettv)
{
int fd;
char_u *p;
int n;
#ifndef O_NONBLOCK
# define O_NONBLOCK 0
#endif
p = get_tv_string(&argvars[0]);
if (*p && !os_isdir(p) && (fd = os_open((char *)p,
O_RDONLY | O_NONBLOCK, 0)) >= 0) {
n = TRUE;
close(fd);
} else
n = FALSE;
rettv->vval.v_number = n;
char_u *p = get_tv_string(&argvars[0]);
rettv->vval.v_number =
(*p && !os_isdir(p) && os_file_is_readable((char*)p));
}
/*