summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2010-01-26 20:04:03 +0000
committerPierre Joye <pajoye@php.net>2010-01-26 20:04:03 +0000
commit573c33b3b7d24354e9a5aa39071dff056217b601 (patch)
treee0129428d92ad8f0001887ea4b3a6a57a01b62c4 /main/streams/plain_wrapper.c
parentdaa380c0cb6ff84325ab5d9f070bf748d420c5fd (diff)
downloadphp-git-573c33b3b7d24354e9a5aa39071dff056217b601.tar.gz
- [DOC] #45986, bad file descriptor warning when rename is used with invalid path, add php_win32_docref2_from_error to display system error for non posix api
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r--main/streams/plain_wrapper.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 1c415b2232..8d94c27c22 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -1080,12 +1080,13 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
ret = VCWD_RENAME(url_from, url_to);
if (ret == -1) {
-#ifdef EXDEV
+#ifndef PHP_WIN32
+# ifdef EXDEV
if (errno == EXDEV) {
struct stat sb;
if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
-#if !defined(TSRM_WIN32) && !defined(NETWARE)
+# if !defined(TSRM_WIN32) && !defined(NETWARE)
if (VCWD_CHMOD(url_to, sb.st_mode)) {
if (errno == EPERM) {
php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
@@ -1104,7 +1105,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
return 0;
}
-#endif
+# endif
VCWD_UNLINK(url_from);
return 1;
}
@@ -1112,8 +1113,14 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
return 0;
}
+# endif
#endif
+
+#ifdef PHP_WIN32
+ php_win32_docref2_from_error(GetLastError(), url_from, url_to TSRMLS_CC);
+#else
php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+#endif
return 0;
}