os_open: impl mch_open with libuv. ref #133

- use return value instead of open_req.result
- libuv uv_fs_open() returns `-errno` instead of always -1
- libuv always sets open_req.result to the return value, _except_ for OOM
  where it only sets the return value. So always use the return value.
- replace calls to mch_open macro.
- update call sites expecting -1 error
This commit is contained in:
Justin M. Keyes
2014-06-14 13:15:07 -04:00
parent bf6b0e3c0a
commit 180c84ed37
8 changed files with 53 additions and 37 deletions

View File

@@ -1045,7 +1045,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
if (os_file_exists(file_name)) {
if (name == NULL || !forceit) {
/* Check we can read it and it's an undo file. */
fd = mch_open((char *)file_name, O_RDONLY, 0);
fd = os_open((char *)file_name, O_RDONLY, 0);
if (fd < 0) {
if (name != NULL || p_verbose > 0) {
if (name == NULL)
@@ -1089,7 +1089,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
goto theend;
}
fd = mch_open((char *)file_name,
fd = os_open((char *)file_name,
O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
if (fd < 0) {
EMSG2(_(e_not_open), file_name);