Revision: 8479
Updated Code
at September 25, 2008 03:33 by stancell
Updated Code
/** * Calculate directory size. * @param string $path without trailing '/' or '\' (eg. '/users/sampleUser', not '/users/sampleUser/') * @return int size in bytes */ function calc_dir_size($path) { $size = 0; if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $current_path = $path . '/' . $entry; if ($entry != '.' && $entry != '..' && !is_link($current_path)) { if (is_file($current_path)) $size += filesize($current_path); elseif (is_dir($current_path)) $size = calc_dir_size($current_path); } } } closedir($handle); return $size; }
Revision: 8478
Updated Code
at September 25, 2008 03:31 by stancell
Updated Code
/** * Calculate directory size. * @param string $path * @return int size in bytes */ function calc_dir_size($path) { $size = 0; if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $current_path = $path . '/' . $entry; if ($entry != '.' && $entry != '..' && !is_link($current_path)) { if (is_file($current_path)) $size += filesize($current_path); elseif (is_dir($current_path)) $size = calc_dir_size($current_path); } } } closedir($handle); return $size; }
Revision: 8477
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 25, 2008 03:29 by stancell
Initial Code
/** * Calculate directory size. * @param string $path * @return int size in bytes */ function calc_dir_size($path) { $size = 0; if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $current_path = $path . '/' . $entry; if ($entry != '.' && $entry != '..' && !is_link($current_path)) { if (is_file($current_path)) $size += filesize($current_path); elseif (is_dir($current_path)) $size = calc_dir_size($current_path); } } } closedir($handle); return $size; }
Initial URL
Initial Description
Initial Title
Calculate directory size
Initial Tags
directory
Initial Language
PHP