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