/** * Retrieve files from filesystem * * @param string cwd * @return string[] */ public function addAll($cwd) { $list = array(); $qs = preg_quote(DIRECTORY_SEPARATOR); foreach ($this->getArguments() as $arg) { if (FALSE !== ($p = strrpos($arg, '='))) { $urn = substr($arg, $p + 1); $arg = substr($arg, 0, $p); } else { $urn = NULL; } if (is_file($arg)) { $this->add(realpath($arg), $cwd, $urn); continue; } // Recursively retrieve all files from directory, ignoring well-known // VCS control files. if (is_dir($arg)) { $collection = new FileCollection($arg); $iterator = new FilteredIOCollectionIterator($collection, new AllOfFilter(array(new NegationOfFilter(new UriMatchesFilter('#' . $qs . '(CVS|\\.svn|\\.git|\\.arch|\\.hg|_darcs|\\.bzr)' . $qs . '#')), new NegationOfFilter(new CollectionFilter()))), TRUE); while ($iterator->hasNext()) { $this->add($iterator->next()->getURI(), $cwd); } continue; } } return $list; }
/** * Helper method * * @param io.collections.iterate.Filter filter * @param bool recursive default FALSE * @return string[] an array of the elements' URIs */ protected function filterFixtureWith($filter, $recursive = FALSE) { $elements = array(); for ($it = new FilteredIOCollectionIterator($this->fixture, $filter, $recursive); $it->hasNext();) { $e = $it->next(); $this->assertSubclass($e, 'io.collections.IOElement'); $elements[] = $e->getURI(); } return $elements; }