本文整理汇总了PHP中Phing::getOutputStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Phing::getOutputStream方法的具体用法?PHP Phing::getOutputStream怎么用?PHP Phing::getOutputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phing
的用法示例。
在下文中一共展示了Phing::getOutputStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Run the task.
*
* @throws BuildException trouble, probably file IO
*/
public function main()
{
if ($this->prefix != null && $this->regex != null) {
throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation());
}
//copy the properties file
$allProps = array();
/* load properties from file if specified, otherwise use Phing's properties */
if ($this->inFile == null) {
// add phing properties
$allProps = $this->getProject()->getProperties();
} elseif ($this->inFile != null) {
if ($this->inFile->exists() && $this->inFile->isDirectory()) {
$message = "srcfile is a directory!";
$this->failOnErrorAction(null, $message, Project::MSG_ERR);
return;
}
if ($this->inFile->exists() && !$this->inFile->canRead()) {
$message = "Can not read from the specified srcfile!";
$this->failOnErrorAction(null, $message, Project::MSG_ERR);
return;
}
try {
$props = new Properties();
$props->load(new PhingFile($this->inFile));
$allProps = $props->getProperties();
} catch (IOException $ioe) {
$message = "Could not read file " . $this->inFile->getAbsolutePath();
$this->failOnErrorAction($ioe, $message, Project::MSG_WARN);
return;
}
}
$os = null;
try {
if ($this->destfile == null) {
$os = Phing::getOutputStream();
$this->saveProperties($allProps, $os);
$this->log($os, Project::MSG_INFO);
} else {
if ($this->destfile->exists() && $this->destfile->isDirectory()) {
$message = "destfile is a directory!";
$this->failOnErrorAction(null, $message, Project::MSG_ERR);
return;
}
if ($this->destfile->exists() && !$this->destfile->canWrite()) {
$message = "Can not write to the specified destfile!";
$this->failOnErrorAction(null, $message, Project::MSG_ERR);
return;
}
$os = new FileOutputStream($this->destfile);
$this->saveProperties($allProps, $os);
}
} catch (IOException $ioe) {
$this->failOnErrorAction($ioe);
}
}
示例2: main
/**
* Execute the task.
* This delegates to the Diagnostics class.
* @throws BuildException on error.
*/
public function main()
{
Diagnostics::doReport(new PrintStream(Phing::getOutputStream()));
}