WP_Filesystem_Base

Base WordPress Filesystem class for which Filesystem implementations extend.

Defined (1)

The class is defined in the following location(s).

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