コード例 #1
0
ファイル: Grabber.php プロジェクト: JPalounek/IconStore
 public function getIcons($folderName, $path)
 {
     unset($this->icons);
     $filesPathes = Finder::findFiles('*')->from($folderName);
     $files = $this->isolateNames($path, $filesPathes);
     foreach ($files as $file) {
         foreach ($this->supportedTypes as $type) {
             if ($this->isolateType($file) == $type) {
                 $this->icons[] = $file;
             }
         }
     }
     $this->iconNames = $this->isolateNames($path, $this->icons);
     return $this->iconNames;
 }
コード例 #2
0
ファイル: FileStorage.php プロジェクト: Balvan/nette
 /**
  * Removes items from the cache by conditions & garbage collector.
  * @param  array  conditions
  * @return void
  */
 public function clean(array $conds)
 {
     $all = !empty($conds[Cache::ALL]);
     $collector = empty($conds);
     // cleaning using file iterator
     if ($all || $collector) {
         $now = time();
         foreach (Nette\Finder::find('*')->from($this->dir)->childFirst() as $entry) {
             $path = (string) $entry;
             if ($entry->isDir()) {
                 // collector: remove empty dirs
                 @rmdir($path);
                 // @ - removing dirs is not necessary
                 continue;
             }
             if ($all) {
                 $this->delete($path);
             } else {
                 // collector
                 $meta = $this->readMeta($path, LOCK_SH);
                 if (!$meta) {
                     continue;
                 }
                 if (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < $now) {
                     $this->delete($path, $meta[self::HANDLE]);
                     continue;
                 }
                 fclose($meta[self::HANDLE]);
             }
         }
         if ($this->context) {
             $this->getJournal()->clean($conds);
         }
         return;
     }
     // cleaning using journal
     if ($this->context) {
         foreach ($this->getJournal()->clean($conds) as $file) {
             $this->delete($file);
         }
     }
 }
コード例 #3
0
ファイル: RobotLoader.php プロジェクト: jff15/travelbot
 /**
  * Scan a directory for PHP files, subdirectories and 'netterobots.txt' file.
  * @param  string
  * @return void
  */
 private function scanDirectory($dir)
 {
     if (is_dir($dir)) {
         $disallow = array();
         $iterator = Nette\Finder::findFiles(String::split($this->acceptFiles, '#[,\\s]+#'))->filter(function ($file) use(&$disallow) {
             return !isset($disallow[$file->getPathname()]);
         })->from($dir)->exclude(String::split($this->ignoreDirs, '#[,\\s]+#'))->filter($filter = function ($dir) use(&$disallow) {
             $path = $dir->getPathname();
             if (is_file("{$path}/netterobots.txt")) {
                 foreach (file("{$path}/netterobots.txt") as $s) {
                     if ($matches = String::match($s, '#^disallow\\s*:\\s*(\\S+)#i')) {
                         $disallow[$path . str_replace('/', DIRECTORY_SEPARATOR, rtrim('/' . ltrim($matches[1], '/'), '/'))] = TRUE;
                     }
                 }
             }
             return !isset($disallow[$path]);
         });
         $filter(new \SplFileInfo($dir));
     } else {
         $iterator = new \ArrayIterator(array(new \SplFileInfo($dir)));
     }
     foreach ($iterator as $entry) {
         $path = $entry->getPathname();
         if (!isset($this->files[$path]) || $this->files[$path] !== $entry->getMTime()) {
             $this->scanScript($path);
         }
     }
 }
コード例 #4
0
	/**
	 * Returns list of available languages.
	 *
	 * @author   Jan Tvrdík
	 * @param    string
	 * @return   array             # => langCode
	 */
	public function getAvailableLanguages($page)
	{
		$langs = array();
		$templates = Nette\Finder::findFiles("$page.*.latte")->in(TEMPLATES_DIR);
		foreach ($templates as $template) {
			$langs[] = substr($template, -8, 2);
		}
		return $langs;
	}
コード例 #5
0
ファイル: AutoUseWorker.php プロジェクト: norbe/AutoUse
	protected function analyse() {
		$this->isSource = TRUE;
		// collect informations from all classes
		foreach(array_merge(array($this->sourceDir), $this->libDirs) as $dir) {
			foreach(Finder::findFiles("*.php")->from($dir)->exclude($this->ignoredDirs) as $fileInfo) {
				debug::timer($fileInfo->getFilename());
				$this->parseFile($fileInfo->getPath() . "/" . $fileInfo->getFilename());
				$this->onOutput(self::OI_FILE_ANALYSED, array(
					self::FILE => $fileInfo->getFilename(),
					self::TIME => debug::timer($fileInfo->getFilename()),
				));
			}

			$this->isSource = FALSE;
		}
	}