: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Checks if a file or directory is writable.
* @param string $path Path to file or directory.
* @return bool Whether $path is writable.
public function is_writable( $path ) {
* Gets the file's last access time.
* @param string $file Path to file.
* @return int|false Unix timestamp representing last access time, false on failure.
public function atime( $file ) {
* Gets the file modification time.
* @param string $file Path to file.
* @return int|false Unix timestamp representing modification time, false on failure.
public function mtime( $file ) {
return $this->ftp->mdtm( $file );
* Gets the file size (in bytes).
* @param string $file Path to file.
* @return int|false Size of the file in bytes on success, false on failure.
public function size( $file ) {
return $this->ftp->filesize( $file );
* Sets the access and modification times of a file.
* Note: If $file doesn't exist, it will be created.
* @param string $file Path to file.
* @param int $time Optional. Modified time to set for file.
* @param int $atime Optional. Access time to set for file.
* @return bool True on success, false on failure.
public function touch( $file, $time = 0, $atime = 0 ) {
* @param string $path Path for new directory.
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
* @param string|int|false $chown Optional. A user name or number (or false to skip chown).
* @param string|int|false $chgrp Optional. A group name or number (or false to skip chgrp).
* @return bool True on success, false on failure.
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
$path = untrailingslashit( $path );
if ( ! $this->ftp->mkdir( $path ) ) {
$this->chmod( $path, $chmod );
* @param string $path Path to directory.
* @param bool $recursive Optional. Whether to recursively remove files/directories.
* @return bool True on success, false on failure.
public function rmdir( $path, $recursive = false ) {
return $this->delete( $path, $recursive );
* Gets details for files in a directory or a specific file.
* @param string $path Path to directory or file.
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
* Array of arrays containing file information. False if unable to list directory contents.
* Array of file information. Note that some elements may not be available on all filesystems.
* @type string $name Name of the file or directory.
* @type string $perms *nix representation of permissions.
* @type string $permsn Octal representation of permissions.
* @type int|string|false $number File number. May be a numeric string. False if not available.
* @type string|false $owner Owner name or ID, or false if not available.
* @type string|false $group File permissions group, or false if not available.
* @type int|string|false $size Size of file in bytes. May be a numeric string.
* False if not available.
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
* False if not available.
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
* false if not available.
* @type string|false $time Last modified time, or false if not available.
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
* @type array|false $files If a directory and `$recursive` is true, contains another array of
* files. False if unable to list directory contents.
public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
if ( $this->is_file( $path ) ) {
$limit_file = basename( $path );
$path = dirname( $path ) . '/';
mbstring_binary_safe_encoding();
$list = $this->ftp->dirlist( $path );
if ( empty( $list ) && ! $this->exists( $path ) ) {
reset_mbstring_encoding();
$path = trailingslashit( $path );
foreach ( $list as $struc ) {
if ( '.' === $struc['name'] || '..' === $struc['name'] ) {
if ( ! $include_hidden && '.' === $struc['name'][0] ) {
if ( $limit_file && $struc['name'] !== $limit_file ) {
if ( 'd' === $struc['type'] ) {
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
$struc['files'] = array();
// Replace symlinks formatted as "source -> target" with just the source name.
if ( $struc['islink'] ) {
$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
// Add the octal representation of the file permissions.
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$ret[ $struc['name'] ] = $struc;
reset_mbstring_encoding();
public function __destruct() {