Summery Summery
Gets details for files in a directory or a specific file.
Syntax Syntax
Parameters Parameters
- $path
-
(Required) Path to directory or file.
- $include_hidden
-
(Optional) Whether to include details of hidden ("." prefixed) files.
Default value: true
- $recursive
-
(Optional) Whether to recursively include file details in nested directories.
Default value: false
Return Return
(array|false) Array of files. False if unable to list directory contents.
- 'name'
(string) Name of the file or directory. - 'perms'
(string) *nix representation of permissions. - 'permsn'
(int) Octal representation of permissions. - 'owner'
(string) Owner name or ID. - 'size'
(int) Size of file in bytes. - 'lastmodunix'
(int) Last modified unix timestamp. - 'lastmod'
(mixed) Last modified month (3 letter) and day (without leading 0). - 'time'
(int) Last modified time. - 'type'
(string) Type of resource. 'f' for file, 'd' for directory. - 'files'
(mixed) If a directory and $recursive is true, contains another array of files.
Source Source
File: wp-admin/includes/class-wp-filesystem-direct.php
} /** * Deletes a directory. * * @since 2.5.0 * * @param string $path Path to directory. * @param bool $recursive Optional. Whether to recursively remove files/directories. * Default false. * @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. * * @since 2.5.0 * * @param string $path Path to directory or file. * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files. * Default true. * @param bool $recursive Optional. Whether to recursively include file details in nested directories. * Default false. * @return array|false { * Array of files. False if unable to list directory contents. * * @type string $name Name of the file or directory. * @type string $perms *nix representation of permissions. * @type int $permsn Octal representation of permissions. * @type string $owner Owner name or ID. * @type int $size Size of file in bytes. * @type int $lastmodunix Last modified unix timestamp. * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0). * @type int $time Last modified time. * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } */ public function dirlist( $path, $include_hidden = true, $recursive = false ) { if ( $this->is_file( $path ) ) { $limit_file = basename( $path ); $path = dirname( $path ); } else { $limit_file = false; } if ( ! $this->is_dir( $path ) || ! $this->is_readable( $path ) ) { return false; } $dir = dir( $path ); if ( ! $dir ) { return false; } $ret = array();
Advertisement
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |