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