function testFileCacheUpdateAll() { $stream = new \qio\Directory\Stream($this->target); $reader = new \qio\Directory\Reader($stream); $state = new \qio\File\Asset\State($this->cache); $state->updateAll(); $list = $reader->scan(); $this->assertEquals(2, count($list)); }
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); }
/** * if directory is provided instead of explicit paths * add all files in directory to path list * use recursive argument to add files in subdirectories * @param string $path * @param boolean $recursive * @return array */ protected function scanTarget($path, $recursive = false) { $newpaths = []; $dir = $this->cache->getDestination(); $stream = new \qio\Directory\Stream($dir); $reader = new \qio\Directory\Reader($stream); $list = $reader->scan(); foreach ($list as $item) { $fullItemPath = $path . DIRECTORY_SEPARATOR . $item; if (is_file($fullItemPath)) { $newpaths[] = $fullItemPath; } elseif ($recursive && is_dir($fullItemPath)) { $newpaths = array_merge($newpaths, $this->scanTarget($fullItemPath, $recursive)); } } return $newpaths; }