Example #1
0
 public function readDirectory($path)
 {
     $filter = $this->filter;
     $modtime = filemtime($path);
     $cached = Cache::get('dir://' . $path, $has, $this->localCache);
     if ($has && $cached['modtime'] >= $modtime) {
         if ($this->cacheTs < $modtime) {
             $this->cacheTs = $modtime;
         }
         foreach ($cached['cache'] as $file => $cache) {
             $this->files[] = $file;
             $this->addFile(File::fromCache($file, $cache, $this->localCache));
         }
         return;
     }
     $this->cached = false;
     $iter = new RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS);
     $cache = array();
     foreach (new RecursiveIteratorIterator($iter) as $file) {
         if (!$file->isfile() || $filter && !$filter($file)) {
             continue;
         }
         $rpath = realpath($file->getPathname());
         $this->files[] = $rpath;
         $file = $this->addFile(new File($file->getPathname(), $this->localCache));
         $cache[$rpath] = $file->ToCache();
     }
     Cache::set('dir://' . $path, compact('modtime', 'cache'), $this->localCache);
     return $this->annotations;
 }