r69365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69364‎ | r69365 | r69366 >
Date:00:29, 15 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on porting WP filesystem abstraction classes
Modified paths:
  • /trunk/extensions/Deployment/includes/filesystems/Ssh2Filesystem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/includes/filesystems/Ssh2Filesystem.php
@@ -342,7 +342,66 @@
343343 * @see Filesystem::listDir
344344 */
345345 public function listDir( $path, $includeHidden = true, $recursive = false ) {
 346+ if ( $this->isFile( $path ) ) {
 347+ $limit_file = basename( $path );
 348+ $path = dirname( $path );
 349+ } else {
 350+ $limit_file = false;
 351+ }
 352+
 353+ if ( !$this->isDir( $path ) ) {
 354+ return false;
 355+ }
 356+
 357+ $ret = array();
 358+ wfSuppressWarnings();
 359+ $dir = dir( 'ssh2.sftp://' . $this->sftpConnection .'/' . ltrim( $path, '/' ) );
 360+ wfRestoreWarnings();
 361+
 362+ if ( !$dir ) {
 363+ return false;
 364+ }
 365+
 366+ while (false !== ( $entry = $dir->read() ) ) {
 367+ $struc = array();
 368+ $struc['name'] = $entry;
 369+
 370+ if (
 371+ ('.' == $struc['name'] || '..' == $struc['name'] )
 372+ || ( !$include_hidden && '.' == $struc['name'][0] )
 373+ || ( $limit_file && $struc['name'] != $limit_file )
 374+ ) {
 375+ continue; // Do not care about these folders.
 376+ }
 377+
 378+ $entryPath = "$path/$entry";
 379+
 380+ $struc['perms'] = $this->getChmod( $entryPath );
 381+ $struc['number'] = false;
 382+ $struc['owner'] = $this->getOwner( $entryPath );
 383+ $struc['group'] = $this->getGroup( $entryPath );
 384+ $struc['size'] = $this->getSize( $entryPath );
 385+ $struc['lastmodunix']= $this->getModificationTime( $entryPath );
 386+ $struc['lastmod'] = date( 'M j', $struc['lastmodunix'] );
 387+ $struc['time'] = date( 'h:i:s', $struc['lastmodunix'] );
 388+ $struc['type'] = $this->isDir( $entryPath ) ? 'd' : 'f';
 389+
 390+ if ( 'd' == $struc['type'] ) {
 391+ if ( $recursive ) {
 392+ $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
 393+ }
 394+ else {
 395+ $struc['files'] = array();
 396+ }
 397+ }
 398+
 399+ $ret[$struc['name']] = $struc;
 400+ }
346401
 402+ $dir->close();
 403+ unset( $dir );
 404+
 405+ return $ret;
347406 }
348407
349408 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r69366Follow up to r69365jeroendedauw00:35, 15 July 2010
r69368Follow up to r69365jeroendedauw00:38, 15 July 2010

Status & tagging log