本文整理汇总了PHP中PhingFile::getCanonicalFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getCanonicalFile方法的具体用法?PHP PhingFile::getCanonicalFile怎么用?PHP PhingFile::getCanonicalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getCanonicalFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* Prepares the command building and execution, i.e.
* changes to the specified directory.
*
* @return void
*/
protected function prepare()
{
if ($this->dir === null) {
return;
}
// expand any symbolic links first
if (!$this->dir->getCanonicalFile()->isDirectory()) {
throw new BuildException("'" . (string) $this->dir . "' is not a valid directory");
}
$this->currdir = getcwd();
@chdir($this->dir->getPath());
}
示例2: execute
/**
* Executes a program and returns the return code.
* Output from command is logged at INFO level.
* @return int Return code from execution.
*/
public function execute()
{
// test if os match
$myos = Phing::getProperty("os.name");
$this->log("Myos = " . $myos, Project::MSG_VERBOSE);
if ($this->os !== null && strpos($this->os, $myos) === false) {
// this command will be executed only on the specified OS
$this->log("Not found in " . $this->os, Project::MSG_VERBOSE);
return 0;
}
if ($this->dir !== null) {
// expand any symbolic links first
if ($this->dir->getCanonicalFile()->isDirectory()) {
$currdir = getcwd();
@chdir($this->dir->getPath());
} else {
throw new BuildException("'" . (string) $this->dir . "' is not a valid directory");
}
}
if ($this->escape == true) {
// FIXME - figure out whether this is correct behavior
$this->command = escapeshellcmd($this->command);
}
if ($this->error !== null) {
$this->command .= ' 2> ' . $this->error->getPath();
$this->log("Writing error output to: " . $this->error->getPath(), $this->logLevel);
}
if ($this->output !== null) {
$this->command .= ' 1> ' . $this->output->getPath();
$this->log("Writing standard output to: " . $this->output->getPath(), $this->logLevel);
} elseif ($this->spawn) {
$this->command .= ' 1>/dev/null';
$this->log("Sending ouptut to /dev/null", $this->logLevel);
}
// If neither output nor error are being written to file
// then we'll redirect error to stdout so that we can dump
// it to screen below.
if ($this->output === null && $this->error === null) {
$this->command .= ' 2>&1';
}
// we ignore the spawn boolean for windows
if ($this->spawn) {
$this->command .= ' &';
}
$this->log("Executing command: " . $this->command, $this->logLevel);
$output = array();
$return = null;
if ($this->passthru) {
passthru($this->command, $return);
} else {
exec($this->command, $output, $return);
}
if ($this->dir !== null) {
@chdir($currdir);
}
foreach ($output as $line) {
$this->log($line, $this->logOutput ? Project::MSG_INFO : Project::MSG_VERBOSE);
}
if ($this->returnProperty) {
$this->project->setProperty($this->returnProperty, $return);
}
if ($this->outputProperty) {
$this->project->setProperty($this->outputProperty, implode("\n", $output));
}
if ($return != 0 && $this->checkreturn) {
throw new BuildException("Task exited with code {$return}");
}
return $return;
}