PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/includes/class-wp-filesystem-base.php

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