本文整理汇总了PHP中gzrewind函数的典型用法代码示例。如果您正苦于以下问题:PHP gzrewind函数的具体用法?PHP gzrewind怎么用?PHP gzrewind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzrewind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _rewind
function _rewind()
{
if (is_resource($this->_file)) {
if ($this->_compress_type == 'gz') {
@gzrewind($this->_file);
} else {
if ($this->_compress_type == 'bz2') {
// ----- Replace missing bztell() and bzseek()
} else {
if ($this->_compress_type == 'none') {
@rewind($this->_file);
} else {
$this->_error('Unknown or missing compression type (' . $this->_compress_type . ')');
}
}
}
}
return true;
}
示例2: gzopen
<?php
$filename = "gzread_variation1.txt.gz";
$h = gzopen($filename, 'w');
$str = "Here is the string to be written. ";
var_dump(gzread($h, 100));
gzwrite($h, $str);
var_dump(gzread($h, 100));
gzrewind($h);
var_dump(gzread($h, 100));
gzclose($h);
$h = gzopen($filename, 'r');
gzpassthru($h);
gzclose($h);
echo "\n";
unlink($filename);
?>
===DONE===
示例3: doRewind
function doRewind()
{
return @gzrewind($this->File);
}
示例4: dirname
<?php
$f = dirname(__FILE__) . "/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzrewind($h, $extra_arg));
var_dump(gzrewind());
gzclose($h);
?>
===DONE===
示例5: _write
/**
* Write the sitemap into a file
*
* @access protected
* @param string $filename the name of the sitemap file
* @param string $sitemap the content of the sitemap
* @return boolean TRUE = success, FALSE = otherwise
*/
function _write($filename, $sitemap)
{
$retval = FALSE;
if (!@touch($filename)) {
COM_errorLog(__CLASS__ . ': Cannot write the sitemap file: ' . $filename);
return $retval;
}
// If file name is '*.gz', then we use gz* functions
$parts = pathinfo($filename);
if (isset($parts['extension']) and strtolower($parts['extension']) == 'gz' and is_callable('gzopen')) {
// Save as a gzipped file
$gp = gzopen($filename, 'r+b');
if ($gp === FALSE) {
COM_errorLog(__CLASS__ . ': Cannot create the sitemap file: ' . $filename);
} else {
if (flock($gp, LOCK_EX)) {
ftruncate($gp, 0);
gzrewind($gp);
gzwrite($gp, $sitemap);
gzclose($gp);
$retval = TRUE;
} else {
COM_errorLog(__CLASS__ . ': Cannot lock the sitemap file for writing: ' . $filename);
}
}
} else {
$fp = fopen($filename, 'r+b');
if ($fp === FALSE) {
COM_errorLog(__CLASS__ . ': Cannot create the sitemap file: ' . $filename);
} else {
if (flock($fp, LOCK_EX)) {
ftruncate($fp, 0);
rewind($fp);
fwrite($fp, $sitemap);
fclose($fp);
$retval = TRUE;
} else {
COM_errorLog(__CLASS__ . ': Cannot lock the sitemap file for writing: ' . $filename);
}
}
}
return $retval;
}
示例6: write
/**
* Write a sitemap into a file
*
* @param string $filename the name of the sitemap file
* @param string $sitemap the content of the sitemap
* @return boolean true = success, false = otherwise
*/
protected function write($filename, $sitemap)
{
$retval = false;
if (!@touch($filename)) {
COM_errorLog(__METHOD__ . ': Cannot write into the sitemap file: ' . $filename);
return $retval;
}
// If file name is '*.gz', then we use Zlib functions
$parts = pathinfo($filename);
if (isset($parts['extension']) && strtolower($parts['extension']) === 'gz' && is_callable('gzopen')) {
// Save as a gzipped file
$gp = @gzopen($filename, 'r+b');
if ($gp === false) {
COM_errorLog(__METHOD__ . ': Cannot create the sitemap file: ' . $filename);
} else {
if (flock($gp, LOCK_EX)) {
ftruncate($gp, 0);
gzrewind($gp);
gzwrite($gp, $sitemap);
flock($gp, LOCK_UN);
gzclose($gp);
$retval = true;
} else {
COM_errorLog(__METHOD__ . ': Cannot lock the sitemap file for writing: ' . $filename);
}
}
} else {
$fp = @fopen($filename, 'r+b');
if ($fp === false) {
COM_errorLog(__METHOD__ . ': Cannot create the sitemap file: ' . $filename);
} else {
if (flock($fp, LOCK_EX)) {
ftruncate($fp, 0);
rewind($fp);
fwrite($fp, $sitemap);
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
$retval = true;
} else {
COM_errorLog(__METHOD__ . ': Cannot lock the sitemap file for writing: ' . $filename);
}
}
}
return $retval;
}
示例7: rewind
/**
* Sets the file position indicator for fp to the beginning of the
* file stream.
*
* This function is identical to a call of $f->seek(0, SEEK_SET)
*
* @throws io.IOException in case of an error
*/
public function rewind()
{
if (FALSE === ($result = gzrewind($this->_fd))) {
throw new IOException('cannot rewind file pointer');
}
return TRUE;
}
示例8: rewind
/**
* Sets the file position indicator for fp to the beginning of the
* file stream.
*
* This function is identical to a call of $f->seek(0, SEEK_SET)
*
* @throws io.IOException in case of an error
*/
public function rewind()
{
if (false === ($result = gzrewind($this->_fd))) {
throw new IOException('cannot rewind file pointer');
}
return true;
}
示例9: var_dump
var_dump(readgzfile($tmpfile));
$zipped = gzencode("testing gzencode");
VS(gzdecode($zipped), "testing gzencode");
$f = gzopen($tmpfile, "w");
VERIFY($f !== false);
gzputs($f, "testing gzputs\n");
gzwrite($f, "<html>testing gzwrite</html>\n");
gzclose($f);
$f = gzopen($tmpfile, "r");
VS(gzread($f, 7), "testing");
VS(gzgetc($f), " ");
VS(gzgets($f), "gzputs\n");
VS(gzgetss($f), "testing gzwrite\n");
VS(gztell($f), 44);
VERIFY(gzeof($f));
VERIFY(gzrewind($f));
VS(gztell($f), 0);
VERIFY(!gzeof($f));
gzseek($f, -7, SEEK_END);
VS(gzgets($f), "testing gzputs\n");
gzclose($f);
$f = gzopen(__DIR__ . "/test_ext_zlib.gz", "r");
gzpassthru($f);
$compressable = str_repeat('A', 1024);
$s = $compressable;
$t = nzcompress($s);
VERIFY(strlen($t) < strlen($s));
$u = nzuncompress($t);
VS($u, $s);
$compressable = str_repeat('\\0', 1024);
$bs = $compressable;
示例10: reset
/**
* Resets the input stream.
*/
public function reset()
{
if (!is_resource($this->_stream)) {
throw new Opl_Stream_Exception('Input stream is not opened.');
}
gzrewind($this->_stream);
}
示例11: rewind
/**
* Rewinds the file pointer to the beginning.
*/
function rewind()
{
if (gzrewind($this->fh) === false) {
throw new \Aimeos\MW\Container\Exception(sprintf('Unable to rewind file "%1$s"', $this->getResource()));
}
$this->position = 0;
$this->data = $this->getData();
}
示例12: rewind
/**
* Go back to the start of reading an open archive
**/
function rewind()
{
if ($this->file_writing) {
return;
}
if ($this->file_handle === false) {
return;
}
if ($this->gz_mode) {
gzrewind($this->file_handle);
} else {
rewind($this->file_handle);
}
$this->seek_length = 0;
}
示例13: rewind
/**
* Rewinds the file pointer to the beginning.
*/
function rewind()
{
if (gzrewind($this->_fh) === false) {
throw new MW_Container_Exception(sprintf('Unable to rewind file "%1$s"', $this->getResource()));
}
$this->_position = 0;
$this->_data = $this->_getData();
}
示例14: gzrewind
/**
* Rewind the position of a gz-file pointer
*
* @param resource $zp The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
*
* @return bool
*/
public function gzrewind($zp) : bool
{
return gzrewind($zp);
}
示例15: gzopen
<?php
$f = "temp2.txt.gz";
$h = gzopen($f, 'w');
gzwrite($h, 'The first string.');
var_dump(gzrewind($h));
gzwrite($h, 'The second string.');
gzclose($h);
$h = gzopen($f, 'r');
gzpassthru($h);
gzclose($h);
unlink($f);
echo "\n";
?>
===DONE===