cvs: TSRM(PHP_5_3) / tsrm_virtual_cwd.c tsrm_virtual_cwd.h php-src NEWS php-src/ext/standard/tests/file bug44805.phpt
[email protected] ("Dmitry Stogov")
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsdmitry1209023102@cvsserver> |
dmitry Thu Apr 24 07:45:02 2008 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/file bug44805.phpt
Modified files:
/php-src NEWS
/TSRM tsrm_virtual_cwd.c tsrm_virtual_cwd.h
Log:
Fixed bug #44805 (rename() function is not portable to Windows). (Pierre)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.161&r2=1.2027.2.547.2.965.2.162&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.161 php-src/NEWS:1.2027.2.547.2.965.2.162
--- php-src/NEWS:1.2027.2.547.2.965.2.161 Mon Apr 21 15:42:26 2008
+++ php-src/NEWS Thu Apr 24 07:45:01 2008
@@ -148,6 +148,7 @@
- Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf)
- Fixed PECL bug #12431 (OCI8 ping functionality is broken). (Oracle Corp.)
+- Fixed bug #44805 (rename() function is not portable to Windows). (Pierre)
- Fixed bug #44648 (Attribute names not checked for wellformedness). (Rob)
- Fixed bug #44414 (Incomplete reporting about abstract methods). (Dmitry)
- Fixed bug #44390 (mysqli_bind_param/bind_result and Object member variables)
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.74.2.9.2.35.2.4&r2=1.74.2.9.2.35.2.5&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.4 TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.5
--- TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.4 Mon Dec 31 07:17:03 2007
+++ TSRM/tsrm_virtual_cwd.c Thu Apr 24 07:45:01 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.4 2007/12/31 07:17:03 sebastian Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.5 2008/04/24 07:45:01 dmitry Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -1042,8 +1042,14 @@
return -1;
}
newname = new_state.cwd;
-
+
+ /* rename on windows will fail if newname already exists.
+ MoveFileEx has to be used */
+#ifdef TSRM_WIN32
+ retval = (MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) == 0) ? -1 : 0;
+#else
retval = rename(oldname, newname);
+#endif
CWD_STATE_FREE(&old_state);
CWD_STATE_FREE(&new_state);
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.h?r1=1.48.2.5.2.8.2.2&r2=1.48.2.5.2.8.2.3&diff_format=u
Index: TSRM/tsrm_virtual_cwd.h
diff -u TSRM/tsrm_virtual_cwd.h:1.48.2.5.2.8.2.2 TSRM/tsrm_virtual_cwd.h:1.48.2.5.2.8.2.3
--- TSRM/tsrm_virtual_cwd.h:1.48.2.5.2.8.2.2 Wed Jan 30 09:41:11 2008
+++ TSRM/tsrm_virtual_cwd.h Thu Apr 24 07:45:01 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.h,v 1.48.2.5.2.8.2.2 2008/01/30 09:41:11 dmitry Exp $ */
+/* $Id: tsrm_virtual_cwd.h,v 1.48.2.5.2.8.2.3 2008/04/24 07:45:01 dmitry Exp $ */
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
@@ -251,7 +251,7 @@
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
#if !defined(TSRM_WIN32)
-#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
+# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
#endif
#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC)
@@ -277,7 +277,13 @@
#define VCWD_OPEN(path, flags) open(path, flags)
#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
#define VCWD_CREAT(path, mode) creat(path, mode)
-#define VCWD_RENAME(oldname, newname) rename(oldname, newname)
+/* rename on windows will fail if newname already exists.
+ MoveFileEx has to be used */
+#if defined(TSRM_WIN32)
+# define VCWD_RENAME(oldname, newname) MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING)
+#else
+# define VCWD_RENAME(oldname, newname) rename(oldname, newname)
+#endif
#define VCWD_CHDIR(path) chdir(path)
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
#define VCWD_GETWD(buf) getwd(buf)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug44805.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug44805.phpt
+++ php-src/ext/standard/tests/file/bug44805.phpt