Jump to content

[SOLVED] is_dir / is_symlink together


map200uk

Recommended Posts

hi,

 

i raealised part of a problem with my script, and it was killing the server ,

 

it was trying to recursive;ly scan symlinks:)

 

anyway, i have tried adding checking in, but am a bit stuck

 

function findMusic($dir) {
     $musicList = array();
     $dirHandle = opendir($dir);
     while (($file = readdir($dirHandle)) !== FALSE) {
          if ($file == "." || $file == "..") continue;
          if (is_dir($dir . "/" . $file)) 
  if(is_dir(is_link($dir)) || (is_dir(is_link($file))) ) 
  $musicList = array_merge($musicList, findMusic($dir . "/" . $file));
          else {
               $extension = end(explode(chr(46), $file));
		   print $extension;
               if (strtolower($extension) == "mp3") { $musicList[] = $dir . "/" . $file; } 
          }
     }
     closedir($dirHandle);
     return $musicList;
}

 

 

im trying to check to see if a directory or file is a symlink if so ignore it else scan

 

map

Link to comment
https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/
Share on other sites

function findMusic($dir) {
     $musicList = array();
     $dirHandle = opendir($dir);
     while (($file = readdir($dirHandle)) !== FALSE) {
          
if(is_dir($dir)) {
	if(!is_link($dir)) {
		$musicList = array_merge($musicList, findMusic($dir . "/" . $file));
	}
  }
  
  $extension = end(explode(chr(46), $file));
		   print $extension;
               if (strtolower($extension) == "mp3") { $musicList[] = $dir . "/" . $file; } 
  
  }
      closedir($dirHandle);
     return $musicList;
     
     }

 

can someone lend a hand? Im getting horribly confused:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.