Bug #15464 Updated: readdir function bug with 0 name directory

From: Date: Sun, 10 Feb 2002 17:48:18 +0000
Subject: Bug #15464 Updated: readdir function bug with 0 name directory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72@lists.php.net to get a copy of this message
ID: 15464 Updated by: laurent.colson@freesbee.fr Reported By: laurent.colson@freesbee.fr -Status: Feedback +Status: Open Bug Type: *Directory/Filesystem functions Operating System: linux PHP Version: 4.1.0 New Comment: Yes, it works with : while(($fichier=readdir($ptr)) !== false) In fact, sorry, it's not really a bug, another thing which works than I tryed : do { $fichier=readdir($ptr); ... }while($fichier<>""); closedir($ptr); This works with the do structure because there is always 2 minimum derectories which are . and .. But your solution is better, thank you very much Friendly, Laurent Previous Comments: ------------------------------------------------------------------------ [2002-02-10 12:29:20] wez@php.net Try while(($fichier=readdir($ptr)) !== false) ------------------------------------------------------------------------ [2002-02-10 12:23:21] elixer@php.net The problem is that the function is returning string "0" which gets converted to FALSE which breaks out of the loop. I don't see an easy way to fix this... ------------------------------------------------------------------------ [2002-02-10 06:04:13] sander@php.net Reproduced. There is something really strange going on... Anyway, create a file or directory 0 and a couple of other (both numeric and non-numeric) files and/or directories. Sometimes it doesn't display any file starting with a number if there's a file called 0. The 0 never shows up. (tested with a recent 4.2.0-dev) ------------------------------------------------------------------------ [2002-02-09 07:58:54] laurent.colson@freesbee.fr Their is a bug when using readdir function with a directory named 0 is in the list. Exemple : Directory /home/www/perso /home/www/perso/0 * 0 is a directory /home/www/perso/1 * 1 is a directory /home/www/perso/2 * 2 is a directory The code : $ptr=opendir("/home/www/perso"); while($fichier=readdir($ptr)) echo "$fichier\n"; closedir($ptr); should be return : . .. 0 1 2 however, it return only : . .. Cause of there is a directory named 0 in the structure. Friendly, Laurent ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15464&edit=1

« previous php.bugs (#72) next »