[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> class-wp-filesystem-base.php (source)

   1  <?php
   2  /**
   3   * Base WordPress Filesystem
   4   *
   5   * @package WordPress
   6   * @subpackage Filesystem
   7   */
   8  
   9  /**
  10   * Base WordPress Filesystem class which Filesystem implementations extend.
  11   *
  12   * @since 2.5.0
  13   */
  14  class WP_Filesystem_Base {
  15  
  16      /**
  17       * Whether to display debug data for the connection.
  18       *
  19       * @since 2.5.0
  20       * @var bool
  21       */
  22      public $verbose = false;
  23  
  24      /**
  25       * Cached list of local filepaths to mapped remote filepaths.
  26       *
  27       * @since 2.7.0
  28       * @var array
  29       */
  30      public $cache = array();
  31  
  32      /**
  33       * The Access method of the current connection, Set automatically.
  34       *
  35       * @since 2.5.0
  36       * @var string
  37       */
  38      public $method = '';
  39  
  40      /**
  41       * @var WP_Error
  42       */
  43      public $errors = null;
  44  
  45      /**
  46       */
  47      public $options = array();
  48  
  49      /**
  50       * Returns the path on the remote filesystem of ABSPATH.
  51       *
  52       * @since 2.7.0
  53       *
  54       * @return string The location of the remote path.
  55       */
  56  	public function abspath() {
  57          $folder = $this->find_folder( ABSPATH );
  58          // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
  59          if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
  60              $folder = '/';
  61          }
  62          return $folder;
  63      }
  64  
  65      /**
  66       * Returns the path on the remote filesystem of WP_CONTENT_DIR.
  67       *
  68       * @since 2.7.0
  69       *
  70       * @return string The location of the remote path.
  71       */
  72  	public function wp_content_dir() {
  73          return $this->find_folder( WP_CONTENT_DIR );
  74      }
  75  
  76      /**
  77       * Returns the path on the remote filesystem of WP_PLUGIN_DIR.
  78       *
  79       * @since 2.7.0
  80       *
  81       * @return string The location of the remote path.
  82       */
  83  	public function wp_plugins_dir() {
  84          return $this->find_folder( WP_PLUGIN_DIR );
  85      }
  86  
  87      /**
  88       * Returns the path on the remote filesystem of the Themes Directory.
  89       *
  90       * @since 2.7.0
  91       *
  92       * @param string|false $theme Optional. The theme stylesheet or template for the directory.
  93       *                            Default false.
  94       * @return string The location of the remote path.
  95       */
  96  	public function wp_themes_dir( $theme = false ) {
  97          $theme_root = get_theme_root( $theme );
  98  
  99          // Account for relative theme roots
 100          if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) {
 101              $theme_root = WP_CONTENT_DIR . $theme_root;
 102          }
 103  
 104          return $this->find_folder( $theme_root );
 105      }
 106  
 107      /**
 108       * Returns the path on the remote filesystem of WP_LANG_DIR.
 109       *
 110       * @since 3.2.0
 111       *
 112       * @return string The location of the remote path.
 113       */
 114  	public function wp_lang_dir() {
 115          return $this->find_folder( WP_LANG_DIR );
 116      }
 117  
 118      /**
 119       * Locates a folder on the remote filesystem.
 120       *
 121       * @since 2.5.0
 122       * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead.
 123       * @see WP_Filesystem::abspath()
 124       * @see WP_Filesystem::wp_content_dir()
 125       * @see WP_Filesystem::wp_plugins_dir()
 126       * @see WP_Filesystem::wp_themes_dir()
 127       * @see WP_Filesystem::wp_lang_dir()
 128       *
 129       * @param string $base The folder to start searching from.
 130       * @param bool   $echo True to display debug information.
 131       *                     Default false.
 132       * @return string The location of the remote path.
 133       */
 134  	public function find_base_dir( $base = '.', $echo = false ) {
 135          _deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
 136          $this->verbose = $echo;
 137          return $this->abspath();
 138      }
 139  
 140      /**
 141       * Locates a folder on the remote filesystem.
 142       *
 143       * @since 2.5.0
 144       * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
 145       * @see WP_Filesystem::abspath()
 146       * @see WP_Filesystem::wp_content_dir()
 147       * @see WP_Filesystem::wp_plugins_dir()
 148       * @see WP_Filesystem::wp_themes_dir()
 149       * @see WP_Filesystem::wp_lang_dir()
 150       *
 151       * @param string $base The folder to start searching from.
 152       * @param bool   $echo True to display debug information.
 153       * @return string The location of the remote path.
 154       */
 155  	public function get_base_dir( $base = '.', $echo = false ) {
 156          _deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
 157          $this->verbose = $echo;
 158          return $this->abspath();
 159      }
 160  
 161      /**
 162       * Locates a folder on the remote filesystem.
 163       *
 164       * Assumes that on Windows systems, Stripping off the Drive
 165       * letter is OK Sanitizes \\ to / in Windows filepaths.
 166       *
 167       * @since 2.7.0
 168       *
 169       * @param string $folder the folder to locate.
 170       * @return string|false The location of the remote path, false on failure.
 171       */
 172  	public function find_folder( $folder ) {
 173          if ( isset( $this->cache[ $folder ] ) ) {
 174              return $this->cache[ $folder ];
 175          }
 176  
 177          if ( stripos( $this->method, 'ftp' ) !== false ) {
 178              $constant_overrides = array(
 179                  'FTP_BASE'        => ABSPATH,
 180                  'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
 181                  'FTP_PLUGIN_DIR'  => WP_PLUGIN_DIR,
 182                  'FTP_LANG_DIR'    => WP_LANG_DIR,
 183              );
 184  
 185              // Direct matches ( folder = CONSTANT/ )
 186              foreach ( $constant_overrides as $constant => $dir ) {
 187                  if ( ! defined( $constant ) ) {
 188                      continue;
 189                  }
 190                  if ( $folder === $dir ) {
 191                      return trailingslashit( constant( $constant ) );
 192                  }
 193              }
 194  
 195              // Prefix Matches ( folder = CONSTANT/subdir )
 196              foreach ( $constant_overrides as $constant => $dir ) {
 197                  if ( ! defined( $constant ) ) {
 198                      continue;
 199                  }
 200                  if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir
 201                      $potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
 202                      $potential_folder = trailingslashit( $potential_folder );
 203  
 204                      if ( $this->is_dir( $potential_folder ) ) {
 205                          $this->cache[ $folder ] = $potential_folder;
 206                          return $potential_folder;
 207                      }
 208                  }
 209              }
 210          } elseif ( 'direct' == $this->method ) {
 211              $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
 212              return trailingslashit( $folder );
 213          }
 214  
 215          $folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out windows drive letter if it's there.
 216          $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
 217  
 218          if ( isset( $this->cache[ $folder ] ) ) {
 219              return $this->cache[ $folder ];
 220          }
 221  
 222          if ( $this->exists( $folder ) ) { // Folder exists at that absolute path.
 223              $folder                 = trailingslashit( $folder );
 224              $this->cache[ $folder ] = $folder;
 225              return $folder;
 226          }
 227          $return = $this->search_for_folder( $folder );
 228          if ( $return ) {
 229              $this->cache[ $folder ] = $return;
 230          }
 231          return $return;
 232      }
 233  
 234      /**
 235       * Locates a folder on the remote filesystem.
 236       *
 237       * Expects Windows sanitized path.
 238       *
 239       * @since 2.7.0
 240       *
 241       * @param string $folder The folder to locate.
 242       * @param string $base   The folder to start searching from.
 243       * @param bool   $loop   If the function has recursed, Internal use only.
 244       * @return string|false The location of the remote path, false to cease looping.
 245       */
 246  	public function search_for_folder( $folder, $base = '.', $loop = false ) {
 247          if ( empty( $base ) || '.' == $base ) {
 248              $base = trailingslashit( $this->cwd() );
 249          }
 250  
 251          $folder = untrailingslashit( $folder );
 252  
 253          if ( $this->verbose ) {
 254              /* translators: 1: Folder to locate, 2: Folder to start searching from. */
 255              printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
 256          }
 257  
 258          $folder_parts     = explode( '/', $folder );
 259          $folder_part_keys = array_keys( $folder_parts );
 260          $last_index       = array_pop( $folder_part_keys );
 261          $last_path        = $folder_parts[ $last_index ];
 262  
 263          $files = $this->dirlist( $base );
 264  
 265          foreach ( $folder_parts as $index => $key ) {
 266              if ( $index == $last_index ) {
 267                  continue; // We want this to be caught by the next code block.
 268              }
 269  
 270              /*
 271               * Working from /home/ to /user/ to /wordpress/ see if that file exists within
 272               * the current folder, If it's found, change into it and follow through looking
 273               * for it. If it can't find WordPress down that route, it'll continue onto the next
 274               * folder level, and see if that matches, and so on. If it reaches the end, and still
 275               * can't find it, it'll return false for the entire function.
 276               */
 277              if ( isset( $files[ $key ] ) ) {
 278  
 279                  // Let's try that folder:
 280                  $newdir = trailingslashit( path_join( $base, $key ) );
 281                  if ( $this->verbose ) {
 282                      /* translators: %s: Directory name. */
 283                      printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
 284                  }
 285  
 286                  // Only search for the remaining path tokens in the directory, not the full path again.
 287                  $newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
 288                  $ret       = $this->search_for_folder( $newfolder, $newdir, $loop );
 289                  if ( $ret ) {
 290                      return $ret;
 291                  }
 292              }
 293          }
 294  
 295          // Only check this as a last resort, to prevent locating the incorrect install.
 296          // All above procedures will fail quickly if this is the right branch to take.
 297          if ( isset( $files[ $last_path ] ) ) {
 298              if ( $this->verbose ) {
 299                  /* translators: %s: Directory name. */
 300                  printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
 301              }
 302              return trailingslashit( $base . $last_path );
 303          }
 304  
 305          // Prevent this function from looping again.
 306          // No need to proceed if we've just searched in /
 307          if ( $loop || '/' == $base ) {
 308              return false;
 309          }
 310  
 311          // As an extra last resort, Change back to / if the folder wasn't found.
 312          // This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
 313          return $this->search_for_folder( $folder, '/', true );
 314  
 315      }
 316  
 317      /**
 318       * Returns the *nix-style file permissions for a file.
 319       *
 320       * From the PHP documentation page for fileperms().
 321       *
 322       * @link https://secure.php.net/manual/en/function.fileperms.php
 323       *
 324       * @since 2.5.0
 325       *
 326       * @param string $file String filename.
 327       * @return string The *nix-style representation of permissions.
 328       */
 329  	public function gethchmod( $file ) {
 330          $perms = intval( $this->getchmod( $file ), 8 );
 331          if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket
 332              $info = 's';
 333          } elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link
 334              $info = 'l';
 335          } elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular
 336              $info = '-';
 337          } elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special
 338              $info = 'b';
 339          } elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory
 340              $info = 'd';
 341          } elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special
 342              $info = 'c';
 343          } elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe
 344              $info = 'p';
 345          } else { // Unknown
 346              $info = 'u';
 347          }
 348  
 349          // Owner
 350          $info .= ( ( $perms & 0x0100 ) ? 'r' : '-' );
 351          $info .= ( ( $perms & 0x0080 ) ? 'w' : '-' );
 352          $info .= ( ( $perms & 0x0040 ) ?
 353                      ( ( $perms & 0x0800 ) ? 's' : 'x' ) :
 354                      ( ( $perms & 0x0800 ) ? 'S' : '-' ) );
 355  
 356          // Group
 357          $info .= ( ( $perms & 0x0020 ) ? 'r' : '-' );
 358          $info .= ( ( $perms & 0x0010 ) ? 'w' : '-' );
 359          $info .= ( ( $perms & 0x0008 ) ?
 360                      ( ( $perms & 0x0400 ) ? 's' : 'x' ) :
 361                      ( ( $perms & 0x0400 ) ? 'S' : '-' ) );
 362  
 363          // World
 364          $info .= ( ( $perms & 0x0004 ) ? 'r' : '-' );
 365          $info .= ( ( $perms & 0x0002 ) ? 'w' : '-' );
 366          $info .= ( ( $perms & 0x0001 ) ?
 367                      ( ( $perms & 0x0200 ) ? 't' : 'x' ) :
 368                      ( ( $perms & 0x0200 ) ? 'T' : '-' ) );
 369          return $info;
 370      }
 371  
 372      /**
 373       * Gets the permissions of the specified file or filepath in their octal format.
 374       *
 375       * @since 2.5.0
 376       *
 377       * @param string $file Path to the file.
 378       * @return string Mode of the file (the last 3 digits).
 379       */
 380  	public function getchmod( $file ) {
 381          return '777';
 382      }
 383  
 384      /**
 385       * Converts *nix-style file permissions to a octal number.
 386       *
 387       * Converts '-rw-r--r--' to 0644
 388       * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
 389       *
 390       * @link https://secure.php.net/manual/en/function.chmod.php#49614
 391       *
 392       * @since 2.5.0
 393       *
 394       * @param string $mode string The *nix-style file permission.
 395       * @return int octal representation
 396       */
 397  	public function getnumchmodfromh( $mode ) {
 398          $realmode = '';
 399          $legal    = array( '', 'w', 'r', 'x', '-' );
 400          $attarray = preg_split( '//', $mode );
 401  
 402          for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
 403              $key = array_search( $attarray[ $i ], $legal );
 404              if ( $key ) {
 405                  $realmode .= $legal[ $key ];
 406              }
 407          }
 408  
 409          $mode  = str_pad( $realmode, 10, '-', STR_PAD_LEFT );
 410          $trans = array(
 411              '-' => '0',
 412              'r' => '4',
 413              'w' => '2',
 414              'x' => '1',
 415          );
 416          $mode  = strtr( $mode, $trans );
 417  
 418          $newmode  = $mode[0];
 419          $newmode .= $mode[1] + $mode[2] + $mode[3];
 420          $newmode .= $mode[4] + $mode[5] + $mode[6];
 421          $newmode .= $mode[7] + $mode[8] + $mode[9];
 422          return $newmode;
 423      }
 424  
 425      /**
 426       * Determines if the string provided contains binary characters.
 427       *
 428       * @since 2.7.0
 429       *
 430       * @param string $text String to test against.
 431       * @return bool True if string is binary, false otherwise.
 432       */
 433  	public function is_binary( $text ) {
 434          return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
 435      }
 436  
 437      /**
 438       * Changes the owner of a file or directory.
 439       *
 440       * Default behavior is to do nothing, override this in your subclass, if desired.
 441       *
 442       * @since 2.5.0
 443       *
 444       * @param string     $file      Path to the file or directory.
 445       * @param string|int $owner     A user name or number.
 446       * @param bool       $recursive Optional. If set to true, changes file owner recursively.
 447       *                              Default false.
 448       * @return bool True on success, false on failure.
 449       */
 450  	public function chown( $file, $owner, $recursive = false ) {
 451          return false;
 452      }
 453  
 454      /**
 455       * Connects filesystem.
 456       *
 457       * @since 2.5.0
 458       * @abstract
 459       *
 460       * @return bool True on success, false on failure (always true for WP_Filesystem_Direct).
 461       */
 462  	public function connect() {
 463          return true;
 464      }
 465  
 466      /**
 467       * Reads entire file into a string.
 468       *
 469       * @since 2.5.0
 470       * @abstract
 471       *
 472       * @param string $file Name of the file to read.
 473       * @return string|false Read data on success, false on failure.
 474       */
 475  	public function get_contents( $file ) {
 476          return false;
 477      }
 478  
 479      /**
 480       * Reads entire file into an array.
 481       *
 482       * @since 2.5.0
 483       * @abstract
 484       *
 485       * @param string $file Path to the file.
 486       * @return array|false File contents in an array on success, false on failure.
 487       */
 488  	public function get_contents_array( $file ) {
 489          return false;
 490      }
 491  
 492      /**
 493       * Writes a string to a file.
 494       *
 495       * @since 2.5.0
 496       * @abstract
 497       *
 498       * @param string    $file     Remote path to the file where to write the data.
 499       * @param string    $contents The data to write.
 500       * @param int|false $mode     Optional. The file permissions as octal number, usually 0644.
 501       *                            Default false.
 502       * @return bool True on success, false on failure.
 503       */
 504  	public function put_contents( $file, $contents, $mode = false ) {
 505          return false;
 506      }
 507  
 508      /**
 509       * Gets the current working directory.
 510       *
 511       * @since 2.5.0
 512       * @abstract
 513       *
 514       * @return string|false The current working directory on success, false on failure.
 515       */
 516  	public function cwd() {
 517          return false;
 518      }
 519  
 520      /**
 521       * Changes current directory.
 522       *
 523       * @since 2.5.0
 524       * @abstract
 525       *
 526       * @param string $dir The new current directory.
 527       * @return bool True on success, false on failure.
 528       */
 529  	public function chdir( $dir ) {
 530          return false;
 531      }
 532  
 533      /**
 534       * Changes the file group.
 535       *
 536       * @since 2.5.0
 537       * @abstract
 538       *
 539       * @param string     $file      Path to the file.
 540       * @param string|int $group     A group name or number.
 541       * @param bool       $recursive Optional. If set to true, changes file group recursively.
 542       *                              Default false.
 543       * @return bool True on success, false on failure.
 544       */
 545  	public function chgrp( $file, $group, $recursive = false ) {
 546          return false;
 547      }
 548  
 549      /**
 550       * Changes filesystem permissions.
 551       *
 552       * @since 2.5.0
 553       * @abstract
 554       *
 555       * @param string    $file      Path to the file.
 556       * @param int|false $mode      Optional. The permissions as octal number, usually 0644 for files,
 557       *                             0755 for directories. Default false.
 558       * @param bool      $recursive Optional. If set to true, changes file group recursively.
 559       *                             Default false.
 560       * @return bool True on success, false on failure.
 561       */
 562  	public function chmod( $file, $mode = false, $recursive = false ) {
 563          return false;
 564      }
 565  
 566      /**
 567       * Gets the file owner.
 568       *
 569       * @since 2.5.0
 570       * @abstract
 571       *
 572       * @param string $file Path to the file.
 573       * @return string|false Username of the owner on success, false on failure.
 574       */
 575  	public function owner( $file ) {
 576          return false;
 577      }
 578  
 579      /**
 580       * Gets the file's group.
 581       *
 582       * @since 2.5.0
 583       * @abstract
 584       *
 585       * @param string $file Path to the file.
 586       * @return string|false The group on success, false on failure.
 587       */
 588  	public function group( $file ) {
 589          return false;
 590      }
 591  
 592      /**
 593       * Copies a file.
 594       *
 595       * @since 2.5.0
 596       * @abstract
 597       *
 598       * @param string    $source      Path to the source file.
 599       * @param string    $destination Path to the destination file.
 600       * @param bool      $overwrite   Optional. Whether to overwrite the destination file if it exists.
 601       *                               Default false.
 602       * @param int|false $mode        Optional. The permissions as octal number, usually 0644 for files,
 603       *                               0755 for dirs. Default false.
 604       * @return bool True on success, false on failure.
 605       */
 606  	public function copy( $source, $destination, $overwrite = false, $mode = false ) {
 607          return false;
 608      }
 609  
 610      /**
 611       * Moves a file.
 612       *
 613       * @since 2.5.0
 614       * @abstract
 615       *
 616       * @param string $source      Path to the source file.
 617       * @param string $destination Path to the destination file.
 618       * @param bool   $overwrite   Optional. Whether to overwrite the destination file if it exists.
 619       *                            Default false.
 620       * @return bool True on success, false on failure.
 621       */
 622  	public function move( $source, $destination, $overwrite = false ) {
 623          return false;
 624      }
 625  
 626      /**
 627       * Deletes a file or directory.
 628       *
 629       * @since 2.5.0
 630       * @abstract
 631       *
 632       * @param string       $file      Path to the file or directory.
 633       * @param bool         $recursive Optional. If set to true, changes file group recursively.
 634       *                                Default false.
 635       * @param string|false $type      Type of resource. 'f' for file, 'd' for directory.
 636       *                                Default false.
 637       * @return bool True on success, false on failure.
 638       */
 639  	public function delete( $file, $recursive = false, $type = false ) {
 640          return false;
 641      }
 642  
 643      /**
 644       * Checks if a file or directory exists.
 645       *
 646       * @since 2.5.0
 647       * @abstract
 648       *
 649       * @param string $file Path to file or directory.
 650       * @return bool Whether $file exists or not.
 651       */
 652  	public function exists( $file ) {
 653          return false;
 654      }
 655  
 656      /**
 657       * Checks if resource is a file.
 658       *
 659       * @since 2.5.0
 660       * @abstract
 661       *
 662       * @param string $file File path.
 663       * @return bool Whether $file is a file.
 664       */
 665  	public function is_file( $file ) {
 666          return false;
 667      }
 668  
 669      /**
 670       * Checks if resource is a directory.
 671       *
 672       * @since 2.5.0
 673       * @abstract
 674       *
 675       * @param string $path Directory path.
 676       * @return bool Whether $path is a directory.
 677       */
 678  	public function is_dir( $path ) {
 679          return false;
 680      }
 681  
 682      /**
 683       * Checks if a file is readable.
 684       *
 685       * @since 2.5.0
 686       * @abstract
 687       *
 688       * @param string $file Path to file.
 689       * @return bool Whether $file is readable.
 690       */
 691  	public function is_readable( $file ) {
 692          return false;
 693      }
 694  
 695      /**
 696       * Checks if a file or directory is writable.
 697       *
 698       * @since 2.5.0
 699       * @abstract
 700       *
 701       * @param string $file Path to file or directory.
 702       * @return bool Whether $file is writable.
 703       */
 704  	public function is_writable( $file ) {
 705          return false;
 706      }
 707  
 708      /**
 709       * Gets the file's last access time.
 710       *
 711       * @since 2.5.0
 712       * @abstract
 713       *
 714       * @param string $file Path to file.
 715       * @return int|false Unix timestamp representing last access time, false on failure.
 716       */
 717  	public function atime( $file ) {
 718          return false;
 719      }
 720  
 721      /**
 722       * Gets the file modification time.
 723       *
 724       * @since 2.5.0
 725       * @abstract
 726       *
 727       * @param string $file Path to file.
 728       * @return int|false Unix timestamp representing modification time, false on failure.
 729       */
 730  	public function mtime( $file ) {
 731          return false;
 732      }
 733  
 734      /**
 735       * Gets the file size (in bytes).
 736       *
 737       * @since 2.5.0
 738       * @abstract
 739       *
 740       * @param string $file Path to file.
 741       * @return int|false Size of the file in bytes on success, false on failure.
 742       */
 743  	public function size( $file ) {
 744          return false;
 745      }
 746  
 747      /**
 748       * Sets the access and modification times of a file.
 749       *
 750       * Note: If $file doesn't exist, it will be created.
 751       *
 752       * @since 2.5.0
 753       * @abstract
 754       *
 755       * @param string $file  Path to file.
 756       * @param int    $time  Optional. Modified time to set for file.
 757       *                      Default 0.
 758       * @param int    $atime Optional. Access time to set for file.
 759       *                      Default 0.
 760       * @return bool True on success, false on failure.
 761       */
 762  	public function touch( $file, $time = 0, $atime = 0 ) {
 763          return false;
 764      }
 765  
 766      /**
 767       * Creates a directory.
 768       *
 769       * @since 2.5.0
 770       * @abstract
 771       *
 772       * @param string     $path  Path for new directory.
 773       * @param int|false  $chmod Optional. The permissions as octal number (or false to skip chmod).
 774       *                          Default false.
 775       * @param string|int $chown Optional. A user name or number (or false to skip chown).
 776       *                          Default false.
 777       * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
 778       *                          Default false.
 779       * @return bool True on success, false on failure.
 780       */
 781  	public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
 782          return false;
 783      }
 784  
 785      /**
 786       * Deletes a directory.
 787       *
 788       * @since 2.5.0
 789       * @abstract
 790       *
 791       * @param string $path      Path to directory.
 792       * @param bool   $recursive Optional. Whether to recursively remove files/directories.
 793       *                          Default false.
 794       * @return bool True on success, false on failure.
 795       */
 796  	public function rmdir( $path, $recursive = false ) {
 797          return false;
 798      }
 799  
 800      /**
 801       * Gets details for files in a directory or a specific file.
 802       *
 803       * @since 2.5.0
 804       * @abstract
 805       *
 806       * @param string $path           Path to directory or file.
 807       * @param bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
 808       *                               Default true.
 809       * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
 810       *                               Default false.
 811       * @return array|false {
 812       *     Array of files. False if unable to list directory contents.
 813       *
 814       *     @type string $name        Name of the file or directory.
 815       *     @type string $perms       *nix representation of permissions.
 816       *     @type int    $permsn      Octal representation of permissions.
 817       *     @type string $owner       Owner name or ID.
 818       *     @type int    $size        Size of file in bytes.
 819       *     @type int    $lastmodunix Last modified unix timestamp.
 820       *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
 821       *     @type int    $time        Last modified time.
 822       *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
 823       *     @type mixed  $files       If a directory and $recursive is true, contains another array of files.
 824       * }
 825       */
 826  	public function dirlist( $path, $include_hidden = true, $recursive = false ) {
 827          return false;
 828      }
 829  
 830  } // WP_Filesystem_Base


Generated: Wed Sep 18 01:00:03 2019 Cross-referenced by PHPXref 0.7.1