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) {
|
foreach ($dirs as $dir => $description) {
|
||||||
$size = FileSystem::folderSize($dir);
|
$size = FileSystem::folderSize($dir, ['htaccess']);
|
||||||
|
|
||||||
$results[] = [
|
$results[] = [
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
|
|
|
@ -45,14 +45,15 @@ class FileSystem
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function folderSize($path)
|
public static function folderSize($path, $exclusions = array())
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$path = realpath($path);
|
$path = realpath($path);
|
||||||
|
|
||||||
if ($path !== false && $path != '' && file_exists($path)) {
|
if ($path !== false && $path != '' && file_exists($path)) {
|
||||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
|
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