Skip to content

Commit

Permalink
MDL-10905 iterating properly through readdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Oct 15, 2007
1 parent f0af72d commit f60ecf6
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion admin/delete.php
Expand Up @@ -54,7 +54,7 @@ function delete_subdirectories($rootdir) {

$dir = opendir($rootdir);

while ($file = readdir($dir)) {
while (false !== ($file = readdir($dir))) {
if ($file != '.' and $file != '..') {
$fullfile = $rootdir .'/'. $file;
if (filetype($fullfile) == 'dir') {
Expand Down
2 changes: 1 addition & 1 deletion backup/bb/restore_bb.php
Expand Up @@ -9,7 +9,7 @@

function get_subdirs($directory){
$opendirectory = opendir( $directory );
while($filename = readdir($opendirectory)) {
while(false !== ($filename = readdir($opendirectory))) {
if (is_dir($directory.$filename) and $filename != ".." and $filename != "."){
$subdirs[] = $filename;
}
Expand Down
8 changes: 4 additions & 4 deletions backup/lib.php
Expand Up @@ -119,7 +119,7 @@ function delete_dir_contents ($dir,$excludeddir="") {
}

// Loop through all directory entries, and construct two temporary arrays containing files and sub directories
while($entry = readdir($handle)) {
while(false !== ($entry = readdir($handle))) {
if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) {
$dir_subdirs[] = $dir. $slash .$entry;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ function list_directories ($rootdir) {
$results = null;

$dir = opendir($rootdir);
while ($file=readdir($dir)) {
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
Expand All @@ -215,7 +215,7 @@ function list_directories_and_files ($rootdir) {
$results = "";

$dir = opendir($rootdir);
while ($file=readdir($dir)) {
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ function backup_copy_dir($from_file,$to_file) {
$status = check_dir_exists($to_file, true, true);
}
$dir = opendir($from_file);
while ($file=readdir($dir)) {
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/db/mysql.php
Expand Up @@ -62,7 +62,7 @@ function assignment_upgrade($oldversion) {
notify("Moving location of assignment files...");

$basedir = opendir("$CFG->dataroot");
while ($dir = readdir($basedir)) {
while (false !== ($dir = readdir($basedir))) {
if ($dir == "." || $dir == ".." || $dir == "users") {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/db/postgres7.php
Expand Up @@ -60,7 +60,7 @@ function assignment_upgrade($oldversion) {
notify("Moving location of assignment files...");

$basedir = opendir("$CFG->dataroot");
while ($dir = readdir($basedir)) {
while (false !== ($dir = readdir($basedir))) {
if ($dir == "." || $dir == ".." || $dir == "users") {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/hotpot/lib.php
Expand Up @@ -476,7 +476,7 @@ function hotpot_add_chain(&$hotpot) {

// get list of hotpot files in this folder
if ($dh = @opendir($xml_quiz->filepath)) {
while ($file = @readdir($dh)) {
while (false !== ($file = @readdir($dh))) {
if (preg_match('/\.(jbc|jcl|jcw|jmt|jmx|jqz|htm|html)$/', $file)) {
$hotpot->references[] = "$xml_quiz->reference/$file";
}
Expand Down
2 changes: 1 addition & 1 deletion mod/resource/type/ims/finder.php
Expand Up @@ -30,7 +30,7 @@

/// Loops though dir building a list of all relevent entries. Ignores files.
/// Asks for deploy if admin user AND no serialized file found.
while (false != ($filename = readdir($repository_dir))) {
while (false !== ($filename = readdir($repository_dir))) {
if ($filename != '.' && $filename != '..' && is_dir("$CFG->repository/$directory/$filename")) {
unset($item);
$item->type = '';
Expand Down
2 changes: 1 addition & 1 deletion mod/resource/type/ims/repository_deploy.php
Expand Up @@ -68,7 +68,7 @@ function ims_deploy_folder($file, $all='') {

$dirpath = "$CFG->repository/$file";
$dir = opendir($dirpath);
while (false != ($filename = readdir($dir))) {
while (false !== ($filename = readdir($dir))) {
if ($filename != '.' && $filename != '..') {
$path = $dirpath.'/'.$filename;
if (is_dir($path) && file_exists("$path/imsmanifest.xml")) {
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/ewiki/ewiki.php
Expand Up @@ -3189,7 +3189,7 @@ function ewiki_eventually_initialize(&$id, &$data, &$action) {
$path=EWIKI_INIT_PAGES;
if (!empty($path)) {
if ($dh = @opendir($path=EWIKI_INIT_PAGES)) {
while ($filename = readdir($dh)) {
while (false !== ($filename = readdir($dh))) {
#### MOODLE CHANGE TO SOLVE BUG #3830. Original doesn't support dots in names.
//Orig->if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) {
if ($filename == clean_filename($filename) && !is_dir($path.'/'.$filename)) {
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/ewiki/plugins/init.php
Expand Up @@ -79,7 +79,7 @@ function ewiki_initialization_wizard($id, &$data, &$action) {
else {
ewiki_database("INIT", array());
if ($dh = @opendir($path=EWIKI_INIT_PAGES)) {
while ($filename = readdir($dh)) {
while (false !== ($filename = readdir($dh))) {
if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) {
$found = ewiki_database("FIND", array($filename));
if (! $found[$filename]) {
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/ewiki/plugins/spages.php
Expand Up @@ -141,7 +141,7 @@ function ewiki_init_spages($dirs, $idprep="") {

#-- read in one directory
$dh = opendir($dir);
while ($fn = readdir($dh)) {
while (false !== ($fn = readdir($dh))) {

#-- skip over . and ..
if ($fn[0] == ".") { continue; }
Expand Down
2 changes: 1 addition & 1 deletion question/format/blackboard_6/format.php
Expand Up @@ -57,7 +57,7 @@ function clean_temp_dir($dir='') {
}

// Loop through all directory entries, and construct two temporary arrays containing files and sub directories
while($entry = readdir($handle)) {
while(false !== ($entry = readdir($handle))) {
if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != ".") {
$dir_subdirs[] = $dir. $slash .$entry;
}
Expand Down
2 changes: 1 addition & 1 deletion question/format/coursetestmanager/format.php
Expand Up @@ -427,7 +427,7 @@ function err($message, $dsn) {
function fulldelete($location) {
if (is_dir($location)) {
$currdir = opendir($location);
while ($file = readdir($currdir)) {
while (false !== ($file = readdir($currdir))) {
if ($file <> ".." && $file <> ".") {
$fullfile = $location."/".$file;
if (is_dir($fullfile)) {
Expand Down

0 comments on commit f60ecf6

Please sign in to comment.