diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fileio.c | 6 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c07597df47..1bee50b717 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -535,11 +535,7 @@ readfile ( if (!newfile) { return FAIL; } - if (perm < 0 -#ifdef ENOENT - && errno == ENOENT -#endif - ) { + if (perm == UV_ENOENT) { /* * Set the 'new-file' flag, so that when the file has * been created by someone else, a ":w" will complain. diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index e13691652a..d59b66e773 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -217,15 +217,16 @@ static int os_stat(const char *name, uv_stat_t *statbuf) /// Get the file permissions for a given file. /// -/// @return `-1` when `name` doesn't exist. +/// @return libuv error code on error. int32_t os_getperm(const char_u *name) FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; - if (os_stat((char *)name, &statbuf) == kLibuvSuccess) { + int stat_result = os_stat((char *)name, &statbuf); + if (stat_result == kLibuvSuccess) { return (int32_t)statbuf.st_mode; } else { - return -1; + return stat_result; } } |