map200uk Posted May 5, 2007 Share Posted May 5, 2007 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 More sharing options...
Lumio Posted May 5, 2007 Share Posted May 5, 2007 (is_dir(is_link($file))) ??? is_link returns true or false. So there can't be a directory named 1 (true) or 0 (false) Link to comment https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/#findComment-246218 Share on other sites More sharing options...
map200uk Posted May 5, 2007 Author Share Posted May 5, 2007 oh, crap so i cant use the 2 together? :| Link to comment https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/#findComment-246225 Share on other sites More sharing options...
map200uk Posted May 5, 2007 Author Share Posted May 5, 2007 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:) Link to comment https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/#findComment-246234 Share on other sites More sharing options...
map200uk Posted May 5, 2007 Author Share Posted May 5, 2007 erm thinking about it now (i tihnk i was getting confused due to spending so much time on this) could i not simply do: if is_dir($dir) && if (is_link(dir) }else { ? Link to comment https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/#findComment-246236 Share on other sites More sharing options...
map200uk Posted May 5, 2007 Author Share Posted May 5, 2007 solved! thanks! Link to comment https://forums.phpfreaks.com/topic/50148-solved-is_dir-is_symlink-together/#findComment-246281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.