From: moodler Date: Sun, 2 May 2004 15:31:23 +0000 (+0000) Subject: This is required for directory resources X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=55fd81779e470b60e547489832a5fe87a940a73e;p=moodle.git This is required for directory resources --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d3815b22a0..277b5556b4 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1520,10 +1520,11 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) { return $filesize; } -function get_directory_list($rootdir, $excludefile="", $descend=true) { +function get_directory_list($rootdir, $excludefile="", $descend=true, $justdirs=false) { /// Returns an array with all the filenames in /// all subdirectories, relative to the given rootdir. /// If excludefile is defined, then that file/directory is ignored +/// If justdirs is defined, then only subdirectories are listed, otherwise just files $dirs = array(); @@ -1540,13 +1541,16 @@ function get_directory_list($rootdir, $excludefile="", $descend=true) { if ($firstchar == "." or $file == "CVS" or $file == $excludefile) { continue; } - $fullfile = $rootdir."/".$file; + $fullfile = "$rootdir/$file"; if ($descend and filetype($fullfile) == "dir") { - $subdirs = get_directory_list($fullfile, $excludefile, $descend); + if ($justdirs) { + $dirs[] = $file; + } + $subdirs = get_directory_list($fullfile, $excludefile, $descend, $justdirs); foreach ($subdirs as $subdir) { - $dirs[] = $file."/".$subdir; + $dirs[] = "$file/$subdir"; } - } else { + } else if (!$justdirs) { $dirs[] = $file; } }