function main($sourceFileName) { if ($this->reg === null || $this->to === null || !$this->reg->matches((string) $sourceFileName)) { return null; } return array($this->replaceReferences($sourceFileName)); }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. * * @param PhingFile $basedir base directory the scan is being done from * @param string $filename the name of the file to check * @param PhingFile $file PhingFile object the selector can use * * @throws BuildException * * @return bool whether the file should be selected or not */ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) { $this->validate(); if ($file->isDirectory()) { return true; } if ($this->myRegExp === null) { $this->myRegExp = new RegularExpression(); $this->myRegExp->setPattern($this->userProvidedExpression); if (!$this->casesensitive) { $this->myRegExp->setIgnoreCase(true); } $this->myExpression = $this->myRegExp->getRegexp($this->getProject()); } $in = null; try { $in = new BufferedReader(new FileReader($file)); $teststr = $in->readLine(); while ($teststr !== null) { if ($this->myExpression->matches($teststr)) { return true; } $teststr = $in->readLine(); } $in->close(); return false; } catch (IOException $ioe) { if ($in) { $in->close(); } throw new BuildException("Could not read file " . $filename); } }
/** * @return string * * @throws BuildException */ protected function doSelect() { $this->reg->setPattern($this->pattern); $this->reg->setModifiers($this->modifiers); $this->reg->setIgnoreCase(!$this->caseSensitive); $output = $this->defaultValue; try { if ($this->reg->matches($this->subject)) { $output = $this->reg->getGroup((int) ltrim($this->match, '$')); } } catch (Exception $e) { throw new BuildException($e); } return $output; }