コード例 #1
0
ファイル: FileInfo.php プロジェクト: bombush/NatsuCon
 /**
  * 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;
 }
コード例 #2
0
ファイル: Configurator.php プロジェクト: bombush/NatsuCon
 /**
  * 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;
 }
コード例 #3
0
ファイル: Thumbs.php プロジェクト: bombush/NatsuCon
 /**
  * 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);
         }
     }
 }
コード例 #4
0
ファイル: FileSystem.php プロジェクト: bombush/NatsuCon
 /**
  * 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();
 }