Jump to content


Photo

Help interpreting is_file() error


  • Please log in to reply
4 replies to this topic

#1 skypanther

skypanther
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 September 2006 - 12:47 AM

Can anyone tell me what the following warning message is telling me?

Warning: is_file(): Stat failed for
files/./././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././. 
in /home/username/public_html/scripts/core/Zip.php on line 1216

The warning is being generated by a script I have that walks a directory tree and adds files to a tar archive. It's happening at the point where the PEAR Tar library is trying to read the files to add them to the tar/gz file. The script works fine on other hosts, leading me to suspect some permission error. But, there's no Stat error code to help me figure things out.

Thanks,
Tim

#2 Monkeymatt

Monkeymatt
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 15 September 2006 - 02:17 AM

It appears that the directory walking is messing up - it should only be reading the files/directories that are not '.' or '..' (current or previous directory). This one is continously going to the same directory, most likely failing eventually because the path is too long.

You need to add a check to only walk through the directory when the filename/directory name is not equal to '.' or '..'

Monkeymatt

#3 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 15 September 2006 - 08:27 AM

Here is a directory walking snippet I posted before, it's recursive so will do all subdir's too.
<?php
function directory_walk($path)
{
    $path = realpath($path);
    $ds = DIRECTORY_SEPARATOR;
    $handle = opendir($path);
    $files = array();

    while (($file = readdir($handle)) !== false)
    {
        if (!in_array($file, array('.', '..')))
        {
            if (is_file($newpath = $path . $ds . $file))
            {
                $files[] = $file;
            }
            else
            {
            $files[$path] = directory_walk($newpath);
            }
        }
    }
    
    return $files;
}
?>


#4 skypanther

skypanther
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 September 2006 - 12:21 PM

My script is made up of code I wrote, plus the standard PEAR Tar and Zip classes. My code builds a list of files to be backed up. That part is working fine. It filters out . and .. and really, all it does is pass an array of file names and directory names to the Tar/Zip class's add() method.

The error I'm seeing happens within the call to add(). I'll check, but I have to believe that the folks over at the PEAR project are smart enough to filter out the . and .. entries when reading a directory. Also, this script works just fine everywhere except at this one host.

My guess is that it's a permission problem, probably a file ownership not file attribute thing. All the docs I can find say that stat() will return an error code if it fails--like, there should be an "errno = ##" part of the error message to tell me why it failed. But, I don't get such an errno in my output.

Thanks for all your suggestions so far.
Tim

#5 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 15 September 2006 - 01:33 PM

no, it's not a file ownership problem - you can see the script is trying to access the directory:
file/./././././././././././././././././././././././././././././././././././././././././././././././././.

that means it is opening the subdir '.' and then opening the subdir '.' etc. etc..






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users