Aggiunta possibilità di definire delle esclusioni per folderSize
This commit is contained in:
parent
830378b812
commit
8c8d379582
|
@ -148,7 +148,7 @@ switch (filter('op')) {
|
|||
];
|
||||
|
||||
foreach ($dirs as $dir => $description) {
|
||||
$size = FileSystem::folderSize($dir);
|
||||
$size = FileSystem::folderSize($dir, ['htaccess']);
|
||||
|
||||
$results[] = [
|
||||
'description' => $description,
|
||||
|
|
|
@ -45,14 +45,15 @@ class FileSystem
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function folderSize($path)
|
||||
public static function folderSize($path, $exclusions = array())
|
||||
{
|
||||
$total = 0;
|
||||
$path = realpath($path);
|
||||
|
||||
if ($path !== false && $path != '' && file_exists($path)) {
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
|
||||
$total += $object->getSize();
|
||||
if (!in_array($object->getExtension(), $exclusions))
|
||||
$total += $object->getSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue