Revert FTP parts of [10919]. fixes #9535 see #9525

git-svn-id: https://develop.svn.wordpress.org/trunk@10930 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-04-14 17:16:44 +00:00
parent 3ae543cf47
commit 077e5b20e9
2 changed files with 12 additions and 22 deletions

View File

@ -169,7 +169,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} }
function getchmod($file) { function getchmod($file) {
$dir = $this->dirlist($file); $dir = $this->dirlist($file);
return $this->getnumchmodfromh( $dir[basename($file)]['perms'] ); return $dir[$file]['permsn'];
} }
function group($file) { function group($file) {
$dir = $this->dirlist($file); $dir = $this->dirlist($file);
@ -187,9 +187,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return ftp_rename($this->link, $source, $destination); return ftp_rename($this->link, $source, $destination);
} }
function delete($file ,$recursive = false ) { function delete($file,$recursive=false) {
if ( empty($file) )
return false;
if ( $this->is_file($file) ) if ( $this->is_file($file) )
return @ftp_delete($this->link, $file); return @ftp_delete($this->link, $file);
if ( !$recursive ) if ( !$recursive )
@ -323,12 +321,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} }
function dirlist($path = '.', $incdot = false, $recursive = false) { function dirlist($path = '.', $incdot = false, $recursive = false) {
if( $this->is_file($path) ) {
if ( substr($path, -1) !== '/') { $limitFile = basename($path);
$limit = basename($path); $path = dirname($path) . '/';
$path = trailingslashit(dirname($path));
} else { } else {
$limit = false; $limitFile = false;
} }
$list = @ftp_rawlist($this->link, '-a ' . $path, false); $list = @ftp_rawlist($this->link, '-a ' . $path, false);
@ -342,10 +339,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
if ( empty($entry) ) if ( empty($entry) )
continue; continue;
if ( '.' == $entry['name'] || '..' == $entry['name'] ) if ( '.' == $entry["name"] || '..' == $entry["name"] )
continue;
if ( $limit && $entry['name'] != $limit )
continue; continue;
$dirlist[ $entry['name'] ] = $entry; $dirlist[ $entry['name'] ] = $entry;

View File

@ -186,7 +186,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
function getchmod($file) { function getchmod($file) {
$dir = $this->dirlist($file); $dir = $this->dirlist($file);
return $this->getnumchmodfromh( $dir[basename($file)]['perms'] ); return $dir[$file]['permsn'];
} }
function group($file) { function group($file) {
@ -281,25 +281,21 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
} }
function dirlist($path = '.', $incdot = false, $recursive = false ) { function dirlist($path = '.', $incdot = false, $recursive = false ) {
if( $this->is_file($path) ) {
if ( substr($path, -1) !== '/') { $limitFile = basename($path);
$limit = basename($path); $path = dirname($path) . '/';
$path = trailingslashit(dirname($path));
} else { } else {
$limit = false; $limitFile = false;
} }
$list = $this->ftp->dirlist($path); $list = $this->ftp->dirlist($path);
if( ! $list ) if( ! $list )
return false; return false;
if( empty($list) ) if( empty($list) )
return array(); return array();
$ret = array(); $ret = array();
foreach ( $list as $struc ) { foreach ( $list as $struc ) {
if ( $limit && $struc['name'] != $limit )
continue;
if ( 'd' == $struc['type'] ) { if ( 'd' == $struc['type'] ) {
$struc['files'] = array(); $struc['files'] = array();