Bramme Posted November 30, 2007 Share Posted November 30, 2007 Okay, this is bugging me. I've written a small class, extending Smarty and I want to go through a folder, checking the files in it. Now I wrote the code first in line, to see if it worked and then converted it to a function in my class (seeing as I'm kinda new to OO and I was merely experimenting). Now I'm getting two warnings, resulting in my script actually not working: Warning: readdir(): supplied argument is not a valid Directory resource Warning: closedir(): supplied argument is not a valid Directory resource Here's my code. <?php require(ROOT.'/libs/Smarty.class.php'); class Modular extends Smarty { var $modulesDir = null; var $uModules = array(); //Construct function, starting Smarty public function __construct() { $this->modulesDir = ROOT.'/admin/mods/'; $this->config_dir = ROOT.'/libs/configs/'; } public function getModules() { if ($handle = opendir($this->modulesDir) || die("Could not open Modules directory")) { while ($file = readdir($handle) !== false) { if($file != "." && $file != ".." && !is_dir($this->modulesDir.$file)) { $Module = fopen($this->modulesDir.$file, 'r'); $modContent = fread($Module, 26); fclose($Module); $this->uModules[] = $file; } } closedir($handle); } return $this->uModules; } /* end class */} ?> First I thought it had something to do with safemode being on, but my host turned it off and it hasn't changed... Damn, i changed it back to how i started off, putting the code directly into index.php, not using a function, but the problem persists. Posting in the general php help area too... Link to comment https://forums.phpfreaks.com/topic/79539-solved-readdirclosedir-error/ Share on other sites More sharing options...
Bramme Posted November 30, 2007 Author Share Posted November 30, 2007 || die("blah") had to be deleted. Link to comment https://forums.phpfreaks.com/topic/79539-solved-readdirclosedir-error/#findComment-402851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.