/** * Get files count in directory * * @param string $path Dir path * * @return integer */ private function getDirFilesCount($path) { $count = 0; $files = Finder::findFiles("*")->from($path); foreach ($files as $file) { if ($file->isFile()) { $count++; } } return $count; }
/** * Get available languages * * @todo Get lanugage title too * * @return array */ private function getLanguages($langDir) { $langs = array($this->defaults["lang"] => $this->defaults["lang"]); foreach (Finder::findFiles("*.json")->in($langDir) as $file) { $langs[$file->getBasename(".json")] = $file->getBasename(".json"); } return $langs; }
/** * Delete all thumbs from directory recursively * * @param string $dir Directory path * * @throws \Exception */ public function deleteDirThumbs($dir) { if (!is_dir($dir)) { throw new \Exception("Directory '{$dir}' not found!"); } $mask = $this->supported; foreach ($mask as $key => $val) { $mask[$key] = "*.{$val}"; } $files = Finder::findFiles($mask)->from($dir); foreach ($files as $file) { $thumbPath = $this->getThumbPath($file->getPathname()); if (file_exists($thumbPath)) { unlink($thumbPath); } } }
/** * Get file/directory size * * @param string $path Path to file/dir * * @return string */ public function getSize($path) { if (is_dir($path)) { $size = 0; $files = Finder::findFiles("*")->from($path); foreach ($files as $file) { $size += $this->getSize($file->getPathName()); } return $size; } $fileSize = new FileSystem\FileSize($path); return $fileSize->getSize(); }