Don't use errno constants for os_open() errors

In Windows we can't assume errno will be set by calls to os_* functions,
instead the return value from os_* functions can be used. This commit fixes two
occurences for os_open().

1. EFBIG is replaced with UV_EFBIG and checked against the return from os_open().
2. EOVERFLOW does not have a corresponding libuv constant, and is not defined
   by open() in Windows - disabled this case with a UNIX guard, and check the return
   value against -EOVERFLOW (libuv errors are negative errno values in Unix).
This commit is contained in:
Rui Abreu Ferreira
2015-10-27 21:47:36 +00:00
parent 5bc6e0dc74
commit d873084581

View File

@@ -578,11 +578,11 @@ readfile (
return OK; /* a new file is not an error */
} else {
filemess(curbuf, sfname, (char_u *)(
# ifdef EFBIG
(errno == EFBIG) ? _("[File too big]") :
# endif
# ifdef EOVERFLOW
(errno == EOVERFLOW) ? _("[File too big]") :
(fd == UV_EFBIG) ? _("[File too big]") :
# if defined(UNIX) && defined(EOVERFLOW)
// libuv only returns -errno in Unix and in Windows open() does not
// set EOVERFLOW
(fd == -EOVERFLOW) ? _("[File too big]") :
# endif
_("[Permission Denied]")), 0);
curbuf->b_p_ro = TRUE; /* must use "w!" now */