public function BackupMigrateDestinationSFTP::list_files in Backup and Migrate SFTP 6
List the files in the remote server.
File
- ./
destinations.sftp.inc, line 109 - Functions to handle the SFTP backup destination.
Class
- BackupMigrateDestinationSFTP
- A destination for sending database backups to an SFTP server.
Code
public function list_files() {
backup_migrate_include('files');
$files = array();
if (!$this
->sftpConnect()) {
return $files;
}
$sftp = $this->sftp;
$path = $this->dest_url['path'];
$dir = "ssh2.sftp://{$sftp}/{$path}";
$handle = opendir($dir);
// List all the files.
while (($file = readdir($handle)) !== FALSE) {
// Skip dotfiles and special paths.
if (drupal_substr($file, 0, 1) == '.') {
continue;
}
$stat = stat("ssh2.sftp://{$sftp}/{$path}/{$file}");
if (!$stat) {
continue;
}
// Skip directories.
if (($stat['mode'] & 0170000) == 040000) {
continue;
}
$files[$file] = new backup_file(array(
'filename' => $file,
'filesize' => $stat['size'],
'filetime' => $stat['mtime'],
));
}
closedir($handle);
return $files;
}