Win32 and opendir() / readdir() revisited
| From: | Sebastian Bergmann | Date: | Fri, 27 Jul 2001 07:32:01 +0000 |
| Subject: | Win32 and opendir() / readdir() revisited | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-61171@lists.php.net to get a copy of this message | ||
Hello,
I did some further investigation into the opendir() / readdir()
weirdness with the latest CVS on Win32 I reported earlier.
<?php
$files = scan_directory('g:/');
function scan_directory($directory) {
static $files;
if (!isset($files)) {
$files = array();
}
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (!@is_dir($directory . '/' . $file)) {
$files[] = $directory . '/' . $file;
} else {
scan_directory($directory . '/' . $file);
}
}
}
closedir($handle);
}
return $files;
}
?>
The above script works fine on Linux, but dies on Win32 when
$directory is on a CD-ROM (ie. read-only device).
Any ideas?
/Sebastian
--
Sebastian Bergmann Measure Traffic & Usability
http://sebastian-bergmann.de/ http://phpOpenTracker.de/