mirror of
https://github.com/php/php-src.git
synced 2024-10-07 01:36:14 +00:00
033ffc206d
- Improve SplFileInfo: . add function getFilename() . add function getPath() -Improve RecursiveTreeIterator . add const BYPASS_CURRENT to bypass current instead of getting its string representation . make key() return the parent key() which calls inner iterators key() - Improve RecursiveDirectoryIterator . add consts CURRENT_AS_FILEINFO, KEY_AS_FILENAME, NEW_CURRENT_AND_KEY . make current() return getFilename() or getFileInfo() depending on flags . make key() return getPathname() or getFilename() depending on flags - Improve DirectoryIterator . make __construct() accept flags as second parameter - Update docu
35 lines
889 B
PHP
Executable File
35 lines
889 B
PHP
Executable File
<?php
|
|
|
|
/** @file directorytree_size.php
|
|
* @brief Program Directory tree size example
|
|
* @ingroup Examples
|
|
* @author Marcus Boerger
|
|
* @date 2003 - 2005
|
|
*
|
|
* Usage: php directorytree_size.php \<path\>
|
|
*
|
|
* Simply specify the path to tree with parameter \<path\>.
|
|
*/
|
|
|
|
if ($argc < 2) {
|
|
echo <<<EOF
|
|
Usage: php ${_SERVER['PHP_SELF']} <path>
|
|
|
|
Displays a graphical directory tree for the given <path> with size info for all
|
|
files.
|
|
|
|
<path> The directory for which to generate the directory tree graph.
|
|
|
|
|
|
EOF;
|
|
exit(1);
|
|
}
|
|
|
|
if (!class_exists("RecursiveTreeIterator", false)) require_once("recursivetreeiterator.inc");
|
|
|
|
echo $argv[1]."\n";
|
|
foreach(new RecursiveTreeIterator(new RecursiveDirectoryIterator($argv[1], RecursiveDirectoryIterator::NEW_CURRENT_AND_KEY), RecursiveTreeIterator::BYPASS_CURRENT) as $file => $fileinfo) {
|
|
echo $file . " (" . $fileinfo->getSize() . ")\n";
|
|
}
|
|
|
|
?>
|