note 96918 deleted from function.ssh2-sftp by danbrown
| From: | danbrown@php.net | Date: | Tue, 23 Mar 2010 14:35:53 +0000 |
| Subject: | note 96918 deleted from function.ssh2-sftp by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167313@lists.php.net to get a copy of this message | ||
Note Submitter: yashamuru at gmail dot com
----
I wanted to have a recursive scanFilesystem, so i modified the function a bit:
function scanFilesystem($remote_file,$recursive = false) {
$sftp = $this->sftp;
$dir = "ssh2.sftp://$sftp$remote_file";
$stream = fopen("ssh2.sftp://$sftp$remote_file",'r');
$tempArray = array();
$handle = opendir($dir);
// List all the files
while (false !== ($file = readdir($handle))) {
if (!in_array($file,array('.','..'))){
//other directories that U don't want scanned should be placed here
if(is_dir($dir.'/'.$file) and $recursive){
$tempArray[$file] = $this->scanFilesystem("$remote_file/$file");
}else{
$tempArray[]=$file;
}
}
}
closedir($handle);
return $tempArray;
}
Cheers,
Ceco