PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

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

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