本文整理汇总了PHP中PhingFile::getCanonicalPath方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getCanonicalPath方法的具体用法?PHP PhingFile::getCanonicalPath怎么用?PHP PhingFile::getCanonicalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getCanonicalPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOutputDirectory
/**
* [REQUIRED] Set the output directory. It will be
* created if it doesn't exist.
* @param PhingFile $outputDirectory
* @return void
* @throws Exception
*/
public function setOutputDirectory(PhingFile $outputDirectory)
{
try {
if (!$outputDirectory->exists()) {
$this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE);
if (!$outputDirectory->mkdirs()) {
throw new IOException("Unable to create Ouptut directory: " . $outputDirectory->getAbsolutePath());
}
}
$this->outputDirectory = $outputDirectory->getCanonicalPath();
} catch (IOException $ioe) {
throw new BuildException($ioe);
}
}
示例2: main
/**
* The main entry point method.
*/
public function main()
{
$project = $this->getProject();
require_once 'Net/FTP.php';
$ftp = new Net_FTP($this->host, $this->port);
if ($this->ssl) {
$ret = $ftp->setSsl();
if (@PEAR::isError($ret)) {
throw new BuildException('SSL connection not supported by php' . ': ' . $ret->getMessage());
} else {
$this->log('Use SSL connection', $this->logLevel);
}
}
$ret = $ftp->connect();
if (@PEAR::isError($ret)) {
throw new BuildException('Could not connect to FTP server ' . $this->host . ' on port ' . $this->port . ': ' . $ret->getMessage());
} else {
$this->log('Connected to FTP server ' . $this->host . ' on port ' . $this->port, $this->logLevel);
}
$ret = $ftp->login($this->username, $this->password);
if (@PEAR::isError($ret)) {
throw new BuildException('Could not login to FTP server ' . $this->host . ' on port ' . $this->port . ' with username ' . $this->username . ': ' . $ret->getMessage());
} else {
$this->log('Logged in to FTP server with username ' . $this->username, $this->logLevel);
}
if ($this->passive) {
$this->log('Setting passive mode', $this->logLevel);
$ret = $ftp->setPassive();
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not set PASSIVE mode: ' . $ret->getMessage());
}
}
// append '/' to the end if necessary
$dir = substr($this->dir, -1) == '/' ? $this->dir : $this->dir . '/';
if ($this->clearFirst) {
// TODO change to a loop through all files and directories within current directory
$this->log('Clearing directory ' . $dir, $this->logLevel);
$ftp->rm($dir, true);
}
// Create directory just in case
$ret = $ftp->mkdir($dir, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dir . ': ' . $ret->getMessage());
}
$ret = $ftp->cd($dir);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not change to directory ' . $dir . ': ' . $ret->getMessage());
} else {
$this->log('Changed directory ' . $dir, $this->logLevel);
}
$fs = FileSystem::getFileSystem();
$convert = $fs->getSeparator() == '\\';
foreach ($this->filesets as $fs) {
// Array for holding directory content informations
$remoteFileInformations = array();
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$srcDirs = $ds->getIncludedDirectories();
foreach ($srcDirs as $dirname) {
if ($convert) {
$dirname = str_replace('\\', '/', $dirname);
}
// Read directory informations, if file exists, else create the directory
if (!$this->_directoryInformations($ftp, $remoteFileInformations, $dirname)) {
$this->log('Will create directory ' . $dirname, $this->logLevel);
$ret = $ftp->mkdir($dirname, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dirname . ': ' . $ret->getMessage());
}
}
if ($this->dirmode) {
if ($this->dirmode == 'inherit') {
$mode = fileperms($dirname);
} else {
$mode = $this->dirmode;
}
// Because Net_FTP does not support a chmod call we call ftp_chmod directly
ftp_chmod($ftp->_handle, $mode, $dirname);
}
}
foreach ($srcFiles as $filename) {
$file = new PhingFile($fromDir->getAbsolutePath(), $filename);
if ($convert) {
$filename = str_replace('\\', '/', $filename);
}
$local_filemtime = filemtime($file->getCanonicalPath());
if (isset($remoteFileInformations[$filename]['stamp'])) {
$remoteFileModificationTime = $remoteFileInformations[$filename]['stamp'];
} else {
$remoteFileModificationTime = 0;
}
if (!$this->depends || $local_filemtime > $remoteFileModificationTime) {
//.........这里部分代码省略.........
示例3: isDestinationUpToDate
/**
* @param PhingFile $compressedArchiveFile
* @throws BuildException
* @internal param array $files array of filenames
* @internal param PhingFile $dir
* @return boolean
*/
protected function isDestinationUpToDate(PhingFile $compressedArchiveFile)
{
if (!$compressedArchiveFile->exists()) {
throw new BuildException("Could not find file " . $compressedArchiveFile->__toString() . " to extract.");
}
$compressedArchiveContent = $this->listArchiveContent($compressedArchiveFile);
if (is_array($compressedArchiveContent)) {
$fileSystem = FileSystem::getFileSystem();
foreach ($compressedArchiveContent as $compressArchivePathInfo) {
$compressArchiveFilename = $compressArchivePathInfo['filename'];
if (!empty($this->removepath) && strlen($compressArchiveFilename) >= strlen($this->removepath)) {
$compressArchiveFilename = preg_replace('/^' . $this->removepath . '/', '', $compressArchiveFilename);
}
$compressArchivePath = new PhingFile($this->todir, $compressArchiveFilename);
if (!$compressArchivePath->exists() || $fileSystem->compareMTimes($compressedArchiveFile->getCanonicalPath(), $compressArchivePath->getCanonicalPath()) == 1) {
return false;
}
}
}
return true;
}
示例4: main
/**
* The main entry point method.
*/
public function main()
{
$project = $this->getProject();
require_once 'Net/FTP.php';
$ftp = new Net_FTP($this->host, $this->port);
$ret = $ftp->connect();
if (@PEAR::isError($ret)) {
throw new BuildException('Could not connect to FTP server ' . $this->host . ' on port ' . $this->port . ': ' . $ret->getMessage());
} else {
$this->log('Connected to FTP server ' . $this->host . ' on port ' . $this->port, $this->logLevel);
}
$ret = $ftp->login($this->username, $this->password);
if (@PEAR::isError($ret)) {
throw new BuildException('Could not login to FTP server ' . $this->host . ' on port ' . $this->port . ' with username ' . $this->username . ': ' . $ret->getMessage());
} else {
$this->log('Logged in to FTP server with username ' . $this->username, $this->logLevel);
}
if ($this->passive) {
$this->log('Setting passive mode', $this->logLevel);
$ret = $ftp->setPassive();
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not set PASSIVE mode: ' . $ret->getMessage());
}
}
// append '/' to the end if necessary
$dir = substr($this->dir, -1) == '/' ? $this->dir : $this->dir . '/';
if ($this->clearFirst) {
// TODO change to a loop through all files and directories within current directory
$this->log('Clearing directory ' . $dir, $this->logLevel);
$ftp->rm($dir, true);
}
// Create directory just in case
$ret = $ftp->mkdir($dir, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dir . ': ' . $ret->getMessage());
}
$ret = $ftp->cd($dir);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not change to directory ' . $dir . ': ' . $ret->getMessage());
} else {
$this->log('Changed directory ' . $dir, $this->logLevel);
}
$fs = FileSystem::getFileSystem();
$convert = $fs->getSeparator() == '\\';
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$srcDirs = $ds->getIncludedDirectories();
foreach ($srcDirs as $dirname) {
if ($convert) {
$dirname = str_replace('\\', '/', $dirname);
}
$this->log('Will create directory ' . $dirname, $this->logLevel);
$ret = $ftp->mkdir($dirname, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dirname . ': ' . $ret->getMessage());
}
}
foreach ($srcFiles as $filename) {
$file = new PhingFile($fromDir->getAbsolutePath(), $filename);
if ($convert) {
$filename = str_replace('\\', '/', $filename);
}
$this->log('Will copy ' . $file->getCanonicalPath() . ' to ' . $filename, $this->logLevel);
$ret = $ftp->put($file->getCanonicalPath(), $filename, true, $this->mode);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not deploy file ' . $filename . ': ' . $ret->getMessage());
}
}
}
$ftp->disconnect();
$this->log('Disconnected from FTP server', $this->logLevel);
}
示例5: isSelected
/**
* 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';
}
}