Skip to content

Commit

Permalink
修改统计文件大小
Browse files Browse the repository at this point in the history
  • Loading branch information
heyi-byte committed Feb 18, 2021
1 parent dddb036 commit 564795a
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,24 @@ public function getChown()
{
return posix_getpwuid(fileowner($this->path));
}
public function dirsize($dir)
public function dirsize($dir, $size = 0)
{
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir . "/" . $file;
if (is_dir($path)) {
$size += $this->dirsize($path);
} elseif (is_file($path)) {
$size += filesize($path);
if (is_dir($dir)) {
@$dh = opendir($dir);
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir . "/" . $file;
if (is_dir($path)) {
$size += $this->dirsize($path, $size);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
} else {
$size += filesize($dir);
}
@closedir($dh);
return $size;
}
public function setSize($size)
Expand Down

0 comments on commit 564795a

Please sign in to comment.