/** * @return FileSize */ public function getSize() { if ($this->isExist()) { return FileSize::object(filesize($this->getPath())); } return FileSize::object(0); }
/** * @return FileSize */ public function getSize() { if ($this->isExist()) { $dir = $this->getPath(); $totalsize = 0; if ($dirstream = @opendir($dir)) { while (false !== ($filename = readdir($dirstream))) { if ($filename != "." && $filename != "..") { if (is_file($dir . "/" . $filename)) { $totalsize += filesize($dir . "/" . $filename); } if (is_dir($dir . "/" . $filename)) { $subdir = new self($dir . "/" . $filename); $totalsize += $subdir->getSize()->getBytes(); } } } } closedir($dirstream); return FileSize::object($totalsize); } return FileSize::object(0); }