private function _checkFile1(PhingFile $file) { // Resolve symbolic links if ($this->followSymlinks && $file->isLink()) { $file = new PhingFile($file->getLinkTarget()); } if ($this->type !== null) { if ($this->type === "dir") { return $file->isDirectory(); } else { if ($this->type === "file") { return $file->isFile(); } } } return $file->exists(); }
/** * Copy a file, takes care of symbolic links * * @param PhingFile $src Source path and name file to copy. * @param PhingFile $dest Destination path and name of new file. * * @return void * @throws Exception if file cannot be copied. */ function copy(PhingFile $src, PhingFile $dest) { global $php_errormsg; if (!$src->isLink()) { return parent::copy($src, $dest); } $srcPath = $src->getAbsolutePath(); $destPath = $dest->getAbsolutePath(); $linkTarget = $src->getLinkTarget(); if (false === @symlink($linkTarget, $destPath)) { $msg = "FileSystem::copy() FAILED. Cannot create symlink from {$destPath} to {$linkTarget}."; throw new Exception($msg); } }
/** * @param $zip */ private function addFilesetsToArchive($zip) { foreach ($this->filesets as $fs) { $fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project); $files = $fs->getFiles($this->project, $this->includeEmpty); for ($i = 0, $fcount = count($files); $i < $fcount; $i++) { $f = new PhingFile($fsBasedir, $files[$i]); $pathInZip = $this->prefix . $f->getPathWithoutBase($fsBasedir); $pathInZip = str_replace('\\', '/', $pathInZip); if ($this->ignoreLinks && $f->isLink()) { continue; } elseif ($f->isDirectory()) { if ($pathInZip != '.') { $zip->addEmptyDir($pathInZip); } } else { $zip->addFile($f->getAbsolutePath(), $pathInZip); } $this->log("Adding " . $f->getPath() . " as " . $pathInZip . " to archive.", Project::MSG_VERBOSE); } } }
/** * @param PhingFile $file * @return bool * @throws IOException */ private function _checkFile1(PhingFile $file) { // Resolve symbolic links if ($this->followSymlinks && $file->isLink()) { $linkTarget = new PhingFile($file->getLinkTarget()); if ($linkTarget->isAbsolute()) { $file = $linkTarget; } else { $fs = FileSystem::getFileSystem(); $file = new PhingFile($fs->resolve($fs->normalize($file->getParent()), $fs->normalize($file->getLinkTarget()))); } } if ($this->type !== null) { if ($this->type === "dir") { return $file->isDirectory(); } else { if ($this->type === "file") { return $file->isFile(); } } } return $file->exists(); }
/** * 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 the base directory the scan is being done from * @param string $filename is the name of the file to check * @param PhingFile $file is a PhingFile object the selector can use * @return boolean Whether the file should be selected or not */ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) { // throw BuildException on error $this->validate(); if ($file->isLink()) { if ($this->type == 'link') { return true; } $this->log($file->getAbsolutePath() . " is a link, proceeding with " . $file->getCanonicalPath() . " instead.", Project::MSG_DEBUG); $file = new PhingFile($file->getCanonicalPath()); } if ($file->isDirectory()) { return $this->type === 'dir'; } else { return $this->type === 'file'; } }