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. |