From: Anatol Belski Date: Fri, 18 Oct 2013 12:01:16 +0000 (-0700) Subject: preserve the error code X-Git-Tag: php-5.6.0alpha1~211^2~8^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=515ef09b62c6d47b79aad5d87db17b8f0bb15f7a;p=php preserve the error code otherwise it'd be cleared by a subsequent calls --- diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 968390d353..e171386b1b 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1695,6 +1695,9 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) / cwd_state old_state; cwd_state new_state; int retval; +#ifdef TSRM_WIN32 + DWORD last_error; +#endif CWD_STATE_COPY(&old_state, &CWDG(cwd)); if (virtual_file_ex(&old_state, oldname, NULL, CWD_EXPAND TSRMLS_CC)) { @@ -1716,6 +1719,7 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) / #ifdef TSRM_WIN32 /* MoveFileEx returns 0 on failure, other way 'round for this function */ retval = (MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED) == 0) ? -1 : 0; + last_error = GetLastError(); #else retval = rename(oldname, newname); #endif @@ -1723,6 +1727,10 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) / CWD_STATE_FREE(&old_state); CWD_STATE_FREE(&new_state); +#ifdef TSRM_WIN32 + SetLastError(last_error); +#endif + return retval; } /* }}} */