: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function size( $file ) {
return @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 ) {
return touch( $file, $time, $atime );
* @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 ) {
// Safe mode fails with a trailing slash under certain PHP versions.
$path = untrailingslashit( $path );
if ( ! @mkdir( $path ) ) {
$this->chmod( $path, $chmod );
$this->chown( $path, $chown );
$this->chgrp( $path, $chgrp );
* @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 false $number File number. Always false in this context.
* @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 );
if ( ! $this->is_dir( $path ) || ! $this->is_readable( $path ) ) {
$path = trailingslashit( $path );
while ( false !== ( $entry = $dir->read() ) ) {
if ( '.' === $struc['name'] || '..' === $struc['name'] ) {
if ( ! $include_hidden && '.' === $struc['name'][0] ) {
if ( $limit_file && $struc['name'] !== $limit_file ) {
$struc['perms'] = $this->gethchmod( $path . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$struc['number'] = false;
$struc['owner'] = $this->owner( $path . $entry );
$struc['group'] = $this->group( $path . $entry );
$struc['size'] = $this->size( $path . $entry );
$struc['lastmodunix'] = $this->mtime( $path . $entry );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . $entry ) ? 'd' : 'f';
if ( 'd' === $struc['type'] ) {
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
$struc['files'] = array();
$ret[ $struc['name'] ] = $struc;