summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2013-10-18 05:01:16 -0700
committerAnatol Belski <ab@php.net>2013-10-18 05:01:16 -0700
commit515ef09b62c6d47b79aad5d87db17b8f0bb15f7a (patch)
tree861fff6d5a7020fb929420847ad82a77e5e4a864
parentcf6ab0e915f95f01a8db1ce7daf70ed36cf49c66 (diff)
downloadphp-git-515ef09b62c6d47b79aad5d87db17b8f0bb15f7a.tar.gz
preserve the error code
otherwise it'd be cleared by a subsequent calls
-rw-r--r--Zend/zend_virtual_cwd.c8
1 files changed, 8 insertions, 0 deletions
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;
}
/* }}} */