Example #1
0
 /**
  * Aggregate interface to perform system-wide cache update
  * @param string|array $path
  * @param boolean $recursive
  * @throws \InvalidArgumentException
  */
 public function updateAll($path = null, $recursive = false)
 {
     if (!is_null($path)) {
         if (is_string($path)) {
             $dir = new \qio\Directory($path);
         } elseif ($path instanceof \qio\Directory) {
             $dir = $path;
         } else {
             throw new \InvalidArgumentException();
         }
     } else {
         $dir = $this->cache->getDirectory();
     }
     $path = $dir->getPath();
     $stream = new \qio\Directory\Stream($dir);
     $reader = new \qio\Directory\Reader($stream);
     if ($stream->open()) {
         $files = [];
         while ($value = $reader->readPath()) {
             if (is_file($path . $value)) {
                 $files[] = $value;
             } elseif (is_dir($path . $value) && $recursive) {
                 $files = array_merge($files, $this->updateAll(new \qio\Directory($value), $recursive));
             }
         }
         $stream->close();
         $this->update($files);
     }
 }
Example #2
0
 function testDirectoryScan()
 {
     $dir = new \qio\Directory(__DIR__);
     $stream = new \qio\Directory\Stream($dir);
     $reader = new \qio\Directory\Reader($stream);
     $stream->open();
     $scan = $reader->scan();
     $stream->close();
     $this->assertTrue(count($scan) > 0);
 }