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:
dd32 2010-02-07 01:59:30 +00:00
parent a87c1e3ca9
commit 65176075c0
2 changed files with 12 additions and 11 deletions

View File

@ -160,8 +160,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
// chmod the file or directory // chmod the file or directory
if ( ! function_exists('ftp_chmod') ) if ( ! function_exists('ftp_chmod') )
return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
return @ftp_chmod($this->link, $mode, $file); return (bool)@ftp_chmod($this->link, $mode, $file);
} }
function chown($file, $owner, $recursive = false ) { function chown($file, $owner, $recursive = false ) {
return false; return false;
@ -242,7 +242,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false; return false;
} }
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
if ( !ftp_mkdir($this->link, $path) ) if ( !@ftp_mkdir($this->link, $path) )
return false; return false;
$this->chmod($path); $this->chmod($path);
if ( $chown ) if ( $chown )
@ -286,8 +286,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
if ( $lcount < 8 ) if ( $lcount < 8 )
return ''; return '';
$b = array(); $b = array();
$b['isdir'] = $lucifer[0]{0} === "d"; $b['isdir'] = $lucifer[0]{0} === 'd';
$b['islink'] = $lucifer[0]{0} === "l"; $b['islink'] = $lucifer[0]{0} === 'l';
if ( $b['isdir'] ) if ( $b['isdir'] )
$b['type'] = 'd'; $b['type'] = 'd';
elseif ( $b['islink'] ) elseif ( $b['islink'] )
@ -334,7 +334,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$list = @ftp_rawlist($this->link, '-a ' . $path, false); $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; return false;
$dirlist = array(); $dirlist = array();
@ -355,9 +355,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$dirlist[ $entry['name'] ] = $entry; $dirlist[ $entry['name'] ] = $entry;
} }
if ( ! $dirlist )
return false;
$ret = array(); $ret = array();
foreach ( (array)$dirlist as $struc ) { foreach ( (array)$dirlist as $struc ) {
if ( 'd' == $struc['type'] ) { if ( 'd' == $struc['type'] ) {

View File

@ -224,7 +224,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
} }
function is_file($file) { 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) { function is_dir($path) {
@ -288,7 +292,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
} }
$list = $this->ftp->dirlist($path); $list = $this->ftp->dirlist($path);
if ( ! $list ) if ( empty($list) && !$this->exists($path) )
return false; return false;
$ret = array(); $ret = array();