本文整理汇总了PHP中PhingFile::getTempDir方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getTempDir方法的具体用法?PHP PhingFile::getTempDir怎么用?PHP PhingFile::getTempDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getTempDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* Returns the stream with an additional linebreak.
*
* @return the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
*/
function read($len = null)
{
if ($this->processed === true) {
return -1;
// EOF
}
// Read
$php = null;
while (($buffer = $this->in->read($len)) !== -1) {
$php .= $buffer;
}
if ($php === null) {
// EOF?
return -1;
}
if (empty($php)) {
$this->log("File is empty!", Project::MSG_WARN);
return '';
// return empty string
}
// write buffer to a temporary file, since php_strip_whitespace() needs a filename
$file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace'));
file_put_contents($file->getAbsolutePath(), $php);
$output = file_get_contents($file->getAbsolutePath()) . "\r\n";
unlink($file->getAbsolutePath());
$this->processed = true;
return $output;
}
示例2: read
/**
* Returns the stream without require_once statements.
*
* @return the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
*/
function read($len = null)
{
if ($this->processed === true) {
return -1;
// EOF
}
// Read
$php = null;
while (($buffer = $this->in->read($len)) !== -1) {
$php .= $buffer;
}
if ($php === null) {
// EOF?
return -1;
}
if (empty($php)) {
$this->log("File is empty!", Project::MSG_WARN);
return '';
// return empty string
}
// write buffer to a temporary file, since php_strip_whitespace() needs a filename
$file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace'));
file_put_contents($file->getAbsolutePath(), $php);
$output = $php;
$matches = array();
if (preg_match_all('|/\\*\\*(.*?)\\*/\\s+(require_once \'.*?\';\\s*)?|s', $output, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
list($all, $docblock, $require) = $match;
if (strstr($docblock, '@see')) {
// Remove docblock and require_once, if it contains @see
$output = str_replace($all, '', $output);
} else {
// Just remove require_once statement
$output = str_replace($require, '', $output);
}
}
}
$output = preg_replace("/(^\\s*require_once.*?;\\s*\$\\s)/sm", "", $output);
unlink($file->getAbsolutePath());
$this->processed = true;
return $output;
}
示例3: doReportTempDir
/**
* try and create a temp file in our temp dir; this
* checks that it has space and access.
* We also do some clock reporting.
*
* @param PrintStream $out
*/
private static function doReportTempDir(PrintStream $out)
{
$tempdir = PhingFile::getTempDir();
if ($tempdir == null) {
$out->println("Warning: php.tmpdir is undefined");
return;
}
$out->println("Temp dir is " . $tempdir);
$tempDirectory = new PhingFile($tempdir);
if (!$tempDirectory->exists()) {
$out->println("Warning, php.tmpdir directory does not exist: " . $tempdir);
return;
}
$now = time();
$tempFile = PhingFile::createTempFile('diag', 'txt', $tempDirectory);
$fileWriter = new FileWriter($tempFile);
$fileWriter->write('some test text');
$fileWriter->close();
$filetime = $tempFile->lastModified();
$tempFile->delete();
$out->println("Temp dir is writeable");
$drift = $filetime - $now;
$out->println("Temp dir alignment with system clock is " . $drift . " s");
if (abs($drift) > 10) {
$out->println("Warning: big clock drift -maybe a network filesystem");
}
}
示例4: read
/**
* Returns the stream with an additional linebreak.
*
* @return the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
*/
function read($len = null)
{
if ($this->processed === true) {
return -1;
// EOF
}
// Read
$php = null;
while (($buffer = $this->in->read($len)) !== -1) {
$php .= $buffer;
}
if ($php === null) {
// EOF?
return -1;
}
if (empty($php)) {
$this->log("File is empty!", Project::MSG_WARN);
return '';
// return empty string
}
// write buffer to a temporary file, since php_strip_whitespace() needs a filename
$file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace'));
file_put_contents($file->getAbsolutePath(), $php);
$output = $php;
$output = preg_replace("/\\/\\*@REMOVE@\\*\\/(.*?)\\/\\*@REMOVE@\\*\\//ims", "", $output);
$output = preg_replace("/;@REMOVE@;(.*?);@REMOVE@;/ims", "", $output);
$output = trim(str_replace(array('<!--@BUILD_ACTIVE@', '@BUILD_ACTIVE@-->', '/*@BUILD_ACTIVE@*/', '<?php /*@BUILD_ACTIVE@', '@BUILD_ACTIVE@*/ ?>', '/*@BUILD_ACTIVE@', '@BUILD_ACTIVE@*/'), "", $output));
unlink($file->getAbsolutePath());
$this->processed = true;
return $output;
}
示例5: read
/**
* Returns the stream with an additional linebreak.
*
* @return the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
*/
function read($len = null)
{
if ($this->processed === true) {
return -1;
// EOF
}
// Read
$php = null;
while (($buffer = $this->in->read($len)) !== -1) {
$php .= $buffer;
}
if ($php === null) {
// EOF?
return -1;
}
if (empty($php)) {
$this->log("File is empty!", Project::MSG_WARN);
return '';
// return empty string
}
// write buffer to a temporary file, since php_strip_whitespace() needs a filename
$file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace'));
file_put_contents($file->getAbsolutePath(), $php);
$output = $php;
$output = preg_replace(array("/^(( | \\* |-- |; |; \\* ).(Author|Date|Revision|LastChangedDate|LastChangedBy|URL).*)(\n|\r\n)/m", "/<\\?php\\s*\\?>/ims"), "", $output);
unlink($file->getAbsolutePath());
$this->processed = true;
return $output;
}