Standardise return values in WP_Filesystem::dirlist(), ::chmod() and ::exists()
git-svn-id: http://svn.automattic.com/wordpress/trunk@12999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a87c1e3ca9
commit
65176075c0
|
@ -160,8 +160,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
|
||||
// chmod the file or directory
|
||||
if ( ! function_exists('ftp_chmod') )
|
||||
return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
||||
return @ftp_chmod($this->link, $mode, $file);
|
||||
return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
||||
return (bool)@ftp_chmod($this->link, $mode, $file);
|
||||
}
|
||||
function chown($file, $owner, $recursive = false ) {
|
||||
return false;
|
||||
|
@ -242,7 +242,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
return false;
|
||||
}
|
||||
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
if ( !ftp_mkdir($this->link, $path) )
|
||||
if ( !@ftp_mkdir($this->link, $path) )
|
||||
return false;
|
||||
$this->chmod($path);
|
||||
if ( $chown )
|
||||
|
@ -286,8 +286,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
if ( $lcount < 8 )
|
||||
return '';
|
||||
$b = array();
|
||||
$b['isdir'] = $lucifer[0]{0} === "d";
|
||||
$b['islink'] = $lucifer[0]{0} === "l";
|
||||
$b['isdir'] = $lucifer[0]{0} === 'd';
|
||||
$b['islink'] = $lucifer[0]{0} === 'l';
|
||||
if ( $b['isdir'] )
|
||||
$b['type'] = 'd';
|
||||
elseif ( $b['islink'] )
|
||||
|
@ -334,7 +334,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
|
||||
$list = @ftp_rawlist($this->link, '-a ' . $path, false);
|
||||
|
||||
if ( $list === false )
|
||||
if ( empty($list) ) // Empty array = non-existant folder(real folder will show . at least
|
||||
return false;
|
||||
|
||||
$dirlist = array();
|
||||
|
@ -355,9 +355,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
$dirlist[ $entry['name'] ] = $entry;
|
||||
}
|
||||
|
||||
if ( ! $dirlist )
|
||||
return false;
|
||||
|
||||
$ret = array();
|
||||
foreach ( (array)$dirlist as $struc ) {
|
||||
if ( 'd' == $struc['type'] ) {
|
||||
|
|
|
@ -224,7 +224,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
function is_file($file) {
|
||||
return $this->is_dir($file) ? false : true;
|
||||
if ( $this->is_dir($file) )
|
||||
return false;
|
||||
if ( $this->exists($file) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_dir($path) {
|
||||
|
@ -288,7 +292,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
$list = $this->ftp->dirlist($path);
|
||||
if ( ! $list )
|
||||
if ( empty($list) && !$this->exists($path) )
|
||||
return false;
|
||||
|
||||
$ret = array();
|
||||
|
|
Loading…
Reference in New Issue