Ignoring directories
Posted: Fri May 26, 2006 6:24 am
Hello!
I have this code for recursive scanning of a dir, but i don't want scan all dirs in a drive for example, and that's why i want to ignore some of them... but don't know how...
How to make this "directory-ignorer" and where in the code to put it?
I didn't write this code!
Thanks!
I have this code for recursive scanning of a dir, but i don't want scan all dirs in a drive for example, and that's why i want to ignore some of them... but don't know how...
Code: Select all
function allFiles($path) {
if (!is_dir($path))
die("$path <<<<<< <b>WRONG DIRECTORY !!!</b>");
if (!@dir($path))
die("<br><br> Can't open directory <b>$path</b>, access or permission is denied !!!");
$dir = dir($path);
$path = $dir->path;
while ($entry = $dir->read()) {
$isDir = "$path/$entry";
if (($entry != ".") && ($entry != "..")) $retAllFiles[] = $entry;
};
$dir->close();
return $retAllFiles;
};
/* -=========== function recursive($path) ===========-
*/
function recursive($path) {
global $numFile , $numDir, $PATH, $DirAndFile;
$result = allFiles($path);
if (empty($result)) return;
while (list ($value, $files) = each($result)) {
if (is_dir("$path/$files")) {
$numDir++;
recursive("$path/$files");
}
else {
$numFile++;
$removePATH = str_replace($PATH, "", $path);
//$DirAndFile[$removePATH][] = "$files";
$DirAndFile[$removePATH][$files] = filesize("$path/$files");
};
};
};I didn't write this code!
Thanks!