public function dirSize($path, $recursive = true) { $result = 0; if (!is_dir($path) || !is_readable($path)) { return 0; } $fd = dir($path); while ($file = $fd->read()) { if ($file != "." && $file != "..") { if (is_dir($path . '/' . $file)) { $result += $recursive ? Demo_Tools::dirSize($path . '/' . $file) : 0; } else { $result += filesize($path . '/' . $file); } } } $fd->close(); return $result; }
/** * Renvoie la taille occupée par le cache (dossier /temp/cache) * * @author Christophe Beyer <*****@*****.**> * @since 2006/12/05 * @return array Tableau avec la taille occupée par les dossiers (index: [folders]) */ public function getCacheSize() { $folder = COPIX_TEMP_PATH . 'cache'; $folders = Demo_Tools::dirSize($folder); return array('folders' => $folders); }