From 4a63d9e5f88feb16ec513b8dba1f8d02bd2ff4d6 Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 9 Apr 2017 12:31:54 +0900 Subject: win: mch_open_rw: specify S_IWRITE #6487 On Windows, `mch_open_rw` is not actually doing what it claims. This manifests as "E301: Oops, lost the swap file !!!" when filename is changed with :file {name}. Steps to reproduce (covered by test/functional/ex_cmds/file_spec.lua): nvim -u NONE :edit test :file test2 E301 Oops, lost the swap file!!! From libuv/src/win/fs.c: void fs__open(uv_fs_t* req) { ... attributes |= FILE_ATTRIBUTE_NORMAL; if (flags & _O_CREAT) { if (!((req->fs.info.mode & ~current_umask) & _S_IWRITE)) { attributes |= FILE_ATTRIBUTE_READONLY; } } --- src/nvim/macros.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 22fd48de9d..9131f8be84 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -120,8 +120,10 @@ /* mch_open_rw(): invoke os_open() with third argument for user R/W. */ #if defined(UNIX) /* open in rw------- mode */ # define mch_open_rw(n, f) os_open((n), (f), (mode_t)0600) +#elif defined(WIN32) +# define mch_open_rw(n, f) os_open((n), (f), S_IREAD | S_IWRITE) #else -# define mch_open_rw(n, f) os_open((n), (f), 0) +# define mch_open_rw(n, f) os_open((n), (f), 0) #endif # define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG)) -- cgit