note 51102 added to function.is-dir

From: Date: Sat, 19 Mar 2005 22:38:55 +0000
Subject: note 51102 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-86698@lists.php.net to get a copy of this message
While working on a php project (my first one =( ). I ran into a bug using is_dir() on my winxp w/ servicepack 2 system. I'm using php 4.3.10.. the problem is whenever i pass is_dir() a pathname that is longer then 256 characters long it will ALWAYS return true. CODE: <?php // Path to multimedia files $mpath = "E:\\armoury\\"; ls($mpath); //echo "MP3 Listing:<br/><br/>"; function ls ($curpath) { $dir = dir($curpath); echo("<b>$curpath</b>"); echo "<blockquote>"; while ($file = $dir->read()) { echo(" <b>"); echo(strlen($curpath.$file)); echo("</b> "); if($file != "." && $file != "..") { if (is_dir($curpath.$file)) { ls($curpath.$file."\\"); } else { echo(" $file<br>"); } } // } } $dir->close(); echo "</blockquote>"; return; } ?> This is the output.. the number preceding the file/directory is the number of characters in it's full path name. You can see where it trips up at: 257 E:\armoury\[ hiphop - dub - reggae - soul ]\A Tribe Called Quest - 1990 - People's Instinctive Travels And The Paths Of Rhythm\A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 10 - Rhythm (Devoted To The Art Of Moving Butts).mp3 The pathname is greater then 256 characters. 229 A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 07 - Bonita Applebum.mp3 227 A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 08 - Can I Kick It.mp3 233 A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 09 - Youthful Expression.mp3 257 E:\armoury\[ hiphop - dub - reggae - soul ]\A Tribe Called Quest - 1990 - People's Instinctive Travels And The Paths Of Rhythm\A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 10 - Rhythm (Devoted To The Art Of Moving Butts).mp3\ 259 260 267 E:\armoury\[ hiphop - dub - reggae - soul ]\A Tribe Called Quest - 1990 - People's Instinctive Travels And The Paths Of Rhythm\A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 10 - Rhythm (Devoted To The Art Of Moving Butts).mp3\index.php\ 269 270 277 E:\armoury\[ hiphop - dub - reggae - soul ]\A Tribe Called Quest - 1990 - People's Instinctive Travels And The Paths Of Rhythm\A Tribe Called Quest - People's Instinctive Travels And The Paths Of Rhythm - 10 - Rhythm (Devoted To The Art Of Moving Butts).mp3\index.php\index.php\ Try it yourself on a large directory structure. ---- Manual Page -- http://www.php.net/manual/en/function.is-dir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51102 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51102&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51102&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51102&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51102&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51102&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51102&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86698) next »