*/
class WP_Filesystem_FTPext extends WP_Filesystem_Base {
public $link;
- public $errors = null;
- public $options = array();
public function __construct($opt='') {
$this->method = 'ftpext';
// Check if possible to use ftp functions.
if ( ! extension_loaded('ftp') ) {
$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
- return false;
+ return;
}
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
else
$this->options['hostname'] = $opt['hostname'];
- if ( ! empty($opt['base']) )
- $this->wp_base = $opt['base'];
-
// Check if the options provided are OK.
if ( empty($opt['username']) )
$this->errors->add('empty_username', __('FTP username is required'));
/**
* @param string $file
- * @return bool|string
+ * @return false|string
*/
public function get_contents( $file ) {
$tempfile = wp_tempnam($file);
return @ftp_chdir($this->link, $dir);
}
- /**
- * @param string $file
- * @param bool $group
- * @param bool $recursive
- */
- public function chgrp($file, $group, $recursive = false ) {
- return false;
- }
-
/**
* @param string $file
* @param int $mode
*/
public function exists($file) {
$list = @ftp_nlist($this->link, $file);
+
+ if ( empty( $list ) && $this->is_dir( $file ) ) {
+ return true; // File is an empty directory.
+ }
+
return !empty($list); //empty list = no file, so invert.
}
/**
if ( !@ftp_mkdir($this->link, $path) )
return false;
$this->chmod($path, $chmod);
- if ( $chown )
- $this->chown($path, $chown);
- if ( $chgrp )
- $this->chgrp($path, $chgrp);
return true;
}