aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-08-16 23:13:55 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-08-17 01:15:04 -0400
commit8f09fa1a49ffa1fc00eabf78c54908d515d0aaa5 (patch)
tree72117f7016f3fbfaf936ffa93745bc52c3f34b4c /src
parentd5cd15e67f8a4cfdc6a29d39efbce2697578783c (diff)
downloadrneovim-8f09fa1a49ffa1fc00eabf78c54908d515d0aaa5.tar.gz
rneovim-8f09fa1a49ffa1fc00eabf78c54908d515d0aaa5.tar.bz2
rneovim-8f09fa1a49ffa1fc00eabf78c54908d515d0aaa5.zip
os/fs.c: remove os_file_is_readonly()
os_file_is_readonly() in its current form is equivalent to !os_file_is_writable(). This does not appear to be a bug, because Vim's use of check_file_readonly() (which we changed to os_file_is_readonly()) is equivalent to !os_file_is_writable() in every case. os_file_is_readonly() also fails this test: returns false if the file is non-read, non-write A more useful form would define behavior under these cases: - path is executable (but not writable) - path is non-existent - path is directory But there is no reason for os_file_is_readonly() to exist, so remove it.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/os/fs.c9
3 files changed, 2 insertions, 11 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index cacef01b19..802a378b07 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2395,7 +2395,7 @@ static int check_readonly(int *forceit, buf_T *buf)
* the file exists and permissions are read-only. */
if (!*forceit && (buf->b_p_ro
|| (os_file_exists(buf->b_ffname)
- && os_file_is_readonly((char *)buf->b_ffname)))) {
+ && !os_file_is_writable((char *)buf->b_ffname)))) {
if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) {
char_u buff[DIALOG_MSG_SIZE];
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c9e11d8fb5..70cdac7947 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2623,7 +2623,7 @@ buf_write (
* Check if the file is really writable (when renaming the file to
* make a backup we won't discover it later).
*/
- file_readonly = os_file_is_readonly((char *)fname);
+ file_readonly = !os_file_is_writable((char *)fname);
if (!forceit && file_readonly) {
if (vim_strchr(p_cpo, CPO_FWRITE) != NULL) {
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index e4776999e5..785c79127f 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -270,15 +270,6 @@ bool os_file_exists(const char_u *name)
return os_stat((char *)name, &statbuf);
}
-/// Check if a file is readonly.
-///
-/// @return `true` if `name` is readonly.
-bool os_file_is_readonly(const char *name)
- FUNC_ATTR_NONNULL_ALL
-{
- return access(name, W_OK) != 0;
-}
-
/// Check if a file is readable.
///
/// @return true if `name` is readable, otherwise false.