Checks if a file or directory exists.
Parameters
$path
stringrequired- Path to file or directory.
Source
public function exists( $path ) {
/*
* Check for empty path. If ftp::nlist() receives an empty path,
* it checks the current working directory and may return true.
*
* See https://core.trac.wordpress.org/ticket/33058.
*/
if ( '' === $path ) {
return false;
}
$list = $this->ftp->nlist( $path );
if ( empty( $list ) && $this->is_dir( $path ) ) {
return true; // File is an empty directory.
}
return ! empty( $list ); // Empty list = no file, so invert.
// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.