dmitry          Thu Oct 19 09:49:56 2006 UTC

  Modified files:              
    /php-src/main       win95nt.h 
    /php-src/main/streams       plain_wrapper.c 
  Log:
  Fixed mkdir("/tmp/foo//bar/log", 0777, true)
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/win95nt.h?r1=1.21&r2=1.22&diff_format=u
Index: php-src/main/win95nt.h
diff -u php-src/main/win95nt.h:1.21 php-src/main/win95nt.h:1.22
--- php-src/main/win95nt.h:1.21 Sun Jan  1 13:09:57 2006
+++ php-src/main/win95nt.h      Thu Oct 19 09:49:56 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: win95nt.h,v 1.21 2006/01/01 13:09:57 sniper Exp $ */
+/* $Id: win95nt.h,v 1.22 2006/10/19 09:49:56 dmitry Exp $ */
 
 /* Defines and types for Windows 95/NT */
 #define HAVE_DECLARED_TIMEZONE
@@ -41,7 +41,7 @@
 #ifndef S_ISREG 
 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
 #endif
-#define chdir(path) SetCurrentDirectory(path)
+#define chdir(path) _chdir(path)
 #define mkdir(a, b)    _mkdir(a)
 #define rmdir(a)       _rmdir(a)
 #define getpid         _getpid
http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.73&r2=1.74&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.73 
php-src/main/streams/plain_wrapper.c:1.74
--- php-src/main/streams/plain_wrapper.c:1.73   Mon Oct  2 18:13:56 2006
+++ php-src/main/streams/plain_wrapper.c        Thu Oct 19 09:49:56 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: plain_wrapper.c,v 1.73 2006/10/02 18:13:56 pollita Exp $ */
+/* $Id: plain_wrapper.c,v 1.74 2006/10/19 09:49:56 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1072,7 +1072,18 @@
                int offset = 0;
 
                buf = estrndup(dir, dir_len);
+
+#ifdef PHP_WIN32
+               e = buf;
+               while (*e) {
+                       if (*e == '/') {
+                               *e = DEFAULT_SLASH;
+                       }
+                       e++;
+               }
+#else
                e = buf + dir_len;
+#endif
 
                if ((p = memchr(buf, DEFAULT_SLASH, dir_len))) {
                        offset = p - buf + 1;
@@ -1084,9 +1095,21 @@
                else {
                        /* find a top level directory we need to create */
                        while ( (p = strrchr(buf + offset, DEFAULT_SLASH)) || 
(offset != 1 && (p = strrchr(buf, DEFAULT_SLASH))) ) {
+                               int n = 0;
+
                                *p = '\0';
+                               while (p > buf && *(p-1) == DEFAULT_SLASH) {
+                                       ++n;
+                                       --p;
+                                       *p = '\0';
+                               }
                                if (VCWD_STAT(buf, &sb) == 0) {
-                                       *p = DEFAULT_SLASH;
+                                       while (1) {
+                                               *p = DEFAULT_SLASH;
+                                               if (!n) break;
+                                               --n;
+                                               ++p;
+                                       }
                                        break;
                                }
                        }
@@ -1100,9 +1123,10 @@
                        }
                        /* create any needed directories if the creation of the 
1st directory worked */
                        while (++p != e) {
-                               if (*p == '\0' && *(p + 1) != '\0') {
+                               if (*p == '\0') {
                                        *p = DEFAULT_SLASH;
-                                       if ((ret = VCWD_MKDIR(buf, 
(mode_t)mode)) < 0) {
+                                       if ((*(p+1) != '\0') &&
+                                           (ret = VCWD_MKDIR(buf, 
(mode_t)mode)) < 0) {
                                                if (options & REPORT_ERRORS) {
                                                        php_error_docref(NULL 
TSRMLS_CC, E_WARNING, "%s", strerror(errno));
                                                }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to