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


Generated: Sat Jul 4 01:00:03 2020 Cross-referenced by PHPXref 0.7.1