Page 2 of 2

Posted: Sat Sep 15, 2007 1:40 pm
by volka
scottayy wrote:Are you saying that it shouldn't follow . and .. if my coding tells it to? Because before I added the check to skip those directories, it definitely followed them and not only sent me into a very long loop
You will find . and .. in every directory
. references the current directory while .. points to the parent directory.
Therefore if you let the function call itself with '.' as parameter you will get an infinite loop

Code: Select all

while (false !== ($file = readdir($handle)))
{
  $path = $dir.'/'.$file;
  if (is_dir($path))
  {
    if ('.'!=$file && '..'!=$file) {
      $this->findJpgs($path);
    }
  }

Posted: Sat Sep 15, 2007 1:54 pm
by s.dot
Yes, I realized that was my problem last night. I've done a directory reader lots of times and for some silly reason I forgot that last night. The script began "working" after I excluded those from being evaluated.

However it didn't really "work" because of is_dir() returning false (when in fact it is true). So now I have to halt development for a bit until I feel like developing remotely. :P

I could use the absolute path (which the user comments for is_dir reports is the solution to the bug), but then I'd have to count the levels and stack the directories to give a recursive absolute path (probably should do this anyways but I'm being lazy at the moment).

Thanks for your insight!