mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
cleaned up the readonly check in readfile()
This commit is contained in:

committed by
Thiago de Arruda

parent
5a2c9e123e
commit
fa2b327e9a
17
src/fileio.c
17
src/fileio.c
@@ -472,16 +472,19 @@ readfile (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check readonly by trying to open the file for writing
|
* Check readonly by trying to open the file for writing.
|
||||||
|
* If this fails, we know that the file is readonly.
|
||||||
*/
|
*/
|
||||||
file_readonly = FALSE;
|
file_readonly = FALSE;
|
||||||
if (read_stdin) {
|
if (!read_buffer && !read_stdin) {
|
||||||
} else if (!read_buffer) {
|
if (!newfile || readonlymode) {
|
||||||
if (!newfile
|
|
||||||
|| readonlymode
|
|
||||||
|| (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0) {
|
|
||||||
file_readonly = TRUE;
|
file_readonly = TRUE;
|
||||||
/* try to open ro */
|
} else if ((fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0) {
|
||||||
|
// opening in readwrite mode failed => file is readonly
|
||||||
|
file_readonly = TRUE;
|
||||||
|
}
|
||||||
|
if (file_readonly == TRUE) {
|
||||||
|
// try to open readonly
|
||||||
fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
|
fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user