Page 1 of 1

NFS and is_dir - problems with directory listing

Posted: Wed Nov 11, 2009 11:22 am
by Eugene-m
Hi!
System information:
- Ubuntu server 9.04
- PHP Version 5.2.6-2ubuntu4
- Apache Version - Apache/2.2.9
- mounted directory on remote server via NFS protocol

Task:
To identify is current file on remote server directory or not

I tried different ways. The first is to use is_dir function and the second is to use DirectoryIterator class. As a result I got that selected directory is a file but it is not true.
It might be a problem with NFS or some specifics in works with the remote filesystem. Unfortunately I didn't find any information in this case. I'd be appreciated if you help me in this situation.

Little example: the task is to list separately files and directories in current directory.

P.S. shell comand file <filename> say me that this file is directory

Code: Select all

 
$dir = "/storage/netstor/unsorted/"; 
$dit = new DirectoryIterator($dir); 
echo "Dirs<br /><br />"; 
foreach($dit as $file )  
{ 
   if(!$file->isDot() && $file->isDir())  
   { 
      echo "FileName: ".$file->getFilename()."<br />"; 
   } 
} 
echo "<br />Files<br /><br />"; 
foreach($dit as $file )  
{ 
   if(!$file->isDot() && !$file->isDir())  
   { 
      echo "FileName: ".$file->getFilename()."<br>"; 
   } 
}
 
Thanks in advanced!
Eugene