#33140 [Com]: Recursive 'mkdir' doesn't work when path includes a non-existent root folder

From: Date: Wed, 15 Mar 2006 08:02:52 +0000
Subject: #33140 [Com]: Recursive 'mkdir' doesn't work when path includes a non-existent root folder
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94358@lists.php.net to get a copy of this message
ID: 33140 Comment by: zefredz at gmail dot com Reported By: cbelin at free dot fr Status: No Feedback Bug Type: Directory function related Operating System: * PHP Version: 5CVS-2005-05-26 New Comment: I have made a little test and I figure out taht giving the full path is not required but that you have to use the backslashes instead of the slashes to make the recursive mkdir work : <code> mkdir ('toto/tutu/titi', 0777, true); # FAILS mkdir ('toto\tutu\titi', 0777, true); # WORKS </code> But when not in recursive mode, mkdir works with either slashes or backslashes. Previous Comments: ------------------------------------------------------------------------ [2006-03-15 08:48:03] zefredz at gmail dot com I have the same bug with PHP 5.0.4 and the given snapshot. But other PHP developpers in my development team does not get the error message while using the same PHP version than mine. The problem occurs on my computer with PHP 5.1 too. The only difference I can figure out between those developers and I is that I am still using Windows XP SP1 while they are using Windows XP SP2. Can this be the cause of the bug ? ------------------------------------------------------------------------ [2005-07-02 01:00:03] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2005-06-24 04:04:29] iliaa@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-06-23 22:18:44] tony2001@php.net When the top directory doesn't exist, the code tries to create directory with empty name because on the previous step we changed first "/" to '\0'. IMO the simplest way is to check if the first character is 0 and change it to DEFAULT_SLASH. Not sure how it would work on Windows though. Index: main/streams/plain_wrapper.c =================================================================== RCS file: /repository/php-src/main/streams/plain_wrapper.c,v retrieving revision 1.47 diff -u -p -d -r1.47 plain_wrapper.c --- main/streams/plain_wrapper.c 20 Jun 2005 15:59:12 -0000 1.47 +++ main/streams/plain_wrapper.c 23 Jun 2005 20:06:47 -0000 @@ -1091,6 +1091,9 @@ static int php_plain_files_mkdir(php_str break; } } + if (*buf == 0) { + *buf = DEFAULT_SLASH; + } if (p == buf) { ret = php_mkdir(dir, mode TSRMLS_CC); } else if (!(ret = php_mkdir(buf, mode TSRMLS_CC))) { ------------------------------------------------------------------------ [2005-05-25 19:54:31] cbelin at free dot fr Note : this bug doesn't appear when you specify a drive letter. <?php mkdir('C:\toto\tata\titi', 0777, true); ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/33140 -- Edit this bug report at http://bugs.php.net/?id=33140&edit=1

« previous php.bugs (#94358) next »