コード例 #1
0
ファイル: BackupModel.php プロジェクト: VNovotna/MP2014
 /**
  * Return array of existing backup files 
  * @param string $path
  * @return array of SplFileInfo 
  */
 public function getBackups($path)
 {
     $files = array();
     $finder = Finder::findFiles('*.zip')->in($path . 'backups/');
     try {
         foreach ($finder->orderByName() as $file) {
             $files[] = $file->getBasename();
         }
         return array_reverse($files);
     } catch (UnexpectedValueException $e) {
         return array();
     }
 }
コード例 #2
0
ファイル: RobotLoader.php プロジェクト: riskatlas/micka
    /**
     * Creates an iterator scaning directory for PHP files, subdirectories and 'netterobots.txt' files.
     * @return Iterator
     */
    private function createFileIterator($dir)
    {
        if (!is_dir($dir)) {
            return new ArrayIterator(array(new SplFileInfo($dir)));
        }
        $ignoreDirs = is_array($this->ignoreDirs) ? $this->ignoreDirs : preg_split('#[,\\s]+#', $this->ignoreDirs);
        $disallow = array();
        foreach ($ignoreDirs as $item) {
            if ($item = realpath($item)) {
                $disallow[$item] = TRUE;
            }
        }
        $iterator = Finder::findFiles(is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\\s]+#', $this->acceptFiles))->filter(create_function('$file', 'extract(NCFix::$vars[' . NCFix::uses(array('disallow' => &$disallow)) . '], EXTR_REFS);
				return !isset($disallow[$file->getPathname()]);
			'))->from($dir)->exclude($ignoreDirs)->filter($filter = create_function('$dir', 'extract(NCFix::$vars[' . NCFix::uses(array('disallow' => &$disallow)) . '], EXTR_REFS);
				$path = $dir->getPathname();
				if (is_file("$path/netterobots.txt")) {
					foreach (file("$path/netterobots.txt") as $s) {
					if (preg_match(\'#^(?:disallow\\\\s*:)?\\\\s*(\\\\S+)#i\', $s, $matches)) {
							$disallow[$path . str_replace(\'/\', DIRECTORY_SEPARATOR, rtrim(\'/\' . ltrim($matches[1], \'/\'), \'/\'))] = TRUE;
						}
					}
				}
				return !isset($disallow[$path]);
			'));
        $filter(new SplFileInfo($dir));
        return $iterator;
    }
コード例 #3
0
ファイル: LogModel.php プロジェクト: VNovotna/MP2014
 public function __construct($filePath, $fileMask = 'latest.log*', $exclude = '*lck')
 {
     $this->finder = Finder::findFiles($fileMask)->exclude($exclude)->in($filePath);
 }
コード例 #4
0
ファイル: FileModel.php プロジェクト: radypala/maga-website
 /**
  * return paths to all images within given $searchPath
  *
  * @param string path to search for images
  * @param string base dirname path of given model used to construct relative path
  * @param bool use relative|"filesystem absolute" paths to images ?
  * @return array
  */
 public static function getImages($searchPath, $baseDir = null, $useRelativePath = true)
 {
     $images = Finder::findFiles('*.jpg')->in($searchPath);
     if ($useRelativePath) {
         if (!$baseDir) {
             throw new ArgumentOutOfRangeException('$baseDir MUST be set if $useRelativePath==true');
         }
         $retImages = array();
         $relativePath = self::getRelativePath($baseDir);
         foreach ($images as $img) {
             array_push($retImages, str_replace(array($baseDir, '\\'), array($relativePath, '/'), $img->getFilename()));
         }
         return $retImages;
     } else {
         return $images;
     }
 }
コード例 #5
0
ファイル: GameUpdateModel.php プロジェクト: VNovotna/MP2014
 /**
  * return all filenames that are already downloaded
  * @param string $path
  * @return array 'filename' => version
  */
 public function getAvailableJars($path)
 {
     $result = array();
     $regex = substr($this->config['regex'], 1, -1);
     foreach (Finder::findFiles($regex)->in($path)->orderByName() as $file) {
         $result[$file->getFilename()] = $this->getVersionFromFileName($file->getFilename());
     }
     return array_reverse($result);
 }
コード例 #6
0
ファイル: FilesModel.php プロジェクト: osmcz/website
 public static function filesSync($id_page, $syncDir)
 {
     $log = array('new' => array(), 'changed' => array());
     $dir = Environment::getVariable('dataDir');
     foreach (Finder::findFiles('*')->from("{$dir}/filesSync/{$syncDir}") as $fullpath) {
         $origpath = str_replace($dir, '', $fullpath);
         $f = self::getFileByOrigpath($origpath);
         $new = false;
         if (!$f) {
             $new = true;
             $f = self::createNew($id_page, $origpath, 'end');
             $f->origpath = str_replace('\\', '/', $origpath);
             $f->visible = 1;
         }
         if ($new or $f->fileMetricsChanged()) {
             $f->fileMetricsUpdate();
             //calls save()  (for the origpath above)
             $f->generatePreviewImage();
             $f->clearPreviewCache();
             $log[$new ? 'new' : 'changed'][] = $f->name;
         }
     }
     return $log;
 }