On 02 Mar 2015 at 19:27, Umberto Salsi <salsi@xxxxxxxxxxxx> wrote: > salsi@xxxxxxxxxxxx (Umberto Salsi) wrote: > >> Discovered today: fopen() opens '.' >> [rest of my bogus comments removed] > > Filed https://bugs.php.net/bug.php?id=69163 about fopen() opening a directory > under Linux, when a more reasonable behavior would be to raise E_WARNING. > Testing for is_dir() is a weak workaroud nobody does and it is not atomic. Disagree. When scanning a directory I do this (leaving out error handling and recursion details): $start = '/path/to/here' $dirh = opendir ($start); while (true) { $nextfile = readdir ($dirh); if ($nextfile===false) break; if ($nextfile=='.' || $nextfile=='..' || $nextfile[0]=='.') continue; if (is_dir($start . $nextfile)==true) // We found a folder { // Recurse into the folder continue; } // Handle the file here } Seems to work. -- Cheers -- Tim
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php