<?php
function directory_scan_rec($basedir,$array_files,$this) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$slash = "\\";
} else {
$slash = "/";
}
if(false !== ($dirHandle = @opendir($basedir))) {
while (false !== ($file = readdir($dirHandle))) {
if (class_exists('gtk')) {
while (gtk::events_pending()) {
gtk::main_iteration();
}
}
if($this->cancel === true) {
return;
}
if($file != "." AND $file != "..") {
if(!is_dir($basedir.$file)) {
if(substr($file,-3) == "mp3" || substr($file,-3) == "ogg" || substr($file,-3) == "wma") { //This if will change soon
$array_files[] = $basedir.$file;
}
} else {
$array_files = directory_scan_rec($basedir.$file.$slash,$array_files,&$this);
}
}
}
closedir($dirHandle);
} else {
echo "'".$basedir."' Es inaccesible\n";
}
return $array_files;
}
function directory_scan($basedir,$this) {
$array_files = array();
$array_files = directory_scan_rec($basedir,$array_files,&$this);
if($this->cancel === true) {
return;
} else {
return $array_files;
}
}
/* FOR A TEST ->
$array = directory_scan("d:/");
var_dump($array);
*/
?>