本文整理汇总了PHP中bzwrite函数的典型用法代码示例。如果您正苦于以下问题:PHP bzwrite函数的具体用法?PHP bzwrite怎么用?PHP bzwrite使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bzwrite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _write
/**
* {@inheritdoc}
*/
protected function _write($data)
{
$result = bzwrite($this->_fileHandler, $data);
if (false === $result) {
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Failed to write data to %1', [$this->_filePath]));
}
}
示例2: _write
/**
* Write data to bz archive
*
* @throws Mage_Exception
* @param $data
*/
protected function _write($data)
{
$result = @bzwrite($this->_fileHandler, $data);
if (false === $result) {
throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
}
}
示例3: bzip
function bzip($infile, $outfile)
{
$fp = fopen($infile, "r");
$data = fread($fp, filesize($infile));
fclose($fp);
$zp = bzopen($outfile, "w");
bzwrite($zp, $data);
bzclose($zp);
}
示例4: write
public function write($file, $data)
{
$open = bzopen($file, 'w');
if (empty($open)) {
throw new FileNotFoundException('Error', 'fileNotFound', $file);
}
$return = bzwrite($open, $data, strlen($data));
bzclose($open);
return $return;
}
示例5: compress
/**
* Compress a file with bzip2
*
* @param string $file
* @return mixed
*/
public static function compress($file)
{
$fullpath = realpath($file);
$file = file_get_contents($file);
// Create the new Bzip2 file resource, write data and close it
$bzResource = bzopen($fullpath . '.bz2', 'w');
bzwrite($bzResource, $file, strlen($file));
bzclose($bzResource);
return $fullpath . '.bz2';
}
示例6: write
function write($data)
{
$data = (string) $data;
if ($this->stream instanceof \IO\Buffer\Stream) {
$length = $this->stream->getLength();
} else {
$length = strlen($data);
}
return bzwrite($this->stream->getPointer(), $data, $length);
}
示例7: _bz2
function _bz2($string, $state)
{
bzwrite($this->fp, $string);
if ($state & PHP_OUTPUT_HANDLER_END) {
bzclose($this->fp);
$return = file_get_contents($this->filename);
unlink($this->filename);
return $return;
}
return "";
}
示例8: compress
public function compress($fileName)
{
$this->tarHandler->compress($fileName);
$bzh = bzopen($fileName . '.tar.bz2', 'wb');
$th = fopen($fileName . ".tar", 'rb');
while (!feof($th)) {
$ustr = fread($th, 1048576);
bzwrite($bzh, $ustr);
}
bzclose($bzh);
fclose($th);
}
示例9: simpleWrite
public function simpleWrite($zp = '', $data = '', $length = 0)
{
if (!is_resource($zp)) {
return Error::set(lang('Error', 'resourceParameter', '1.(zp)'));
}
if (!isValue($data)) {
return Error::set(lang('Error', 'valueParameter', '2.(data)'));
}
if ($length === 0) {
$length = strlen($data);
}
return bzwrite($zp, $data, $length);
}
示例10: write
public function write($file = '', $data = '', $mode = NULL)
{
if (!is_string($file) || empty($file)) {
return Error::set('Error', 'stringParameter', '1.(file)');
}
if (!is_scalar($data)) {
return Error::set('Error', 'valueParameter', '2.(data)');
}
$open = bzopen($file, 'w');
if (empty($open)) {
return Error::set('Error', 'fileNotFound', $file);
}
$return = bzwrite($open, $data, strlen($data));
bzclose($open);
return $return;
}
示例11: test_bzwrite
function test_bzwrite()
{
global $tmpfile;
$str = "HipHop for";
$bz = bzopen($tmpfile, "w");
VERIFY($bz !== false);
VS(bzwrite($bz, $str), 10);
bzflush($bz);
VERIFY(bzclose($bz));
$bz = bzopen($tmpfile, "r");
$ret = bzread($bz, 10000);
VS($ret, $str);
VERIFY(bzclose($bz));
VS($ret, $str);
unlink($tmpfile);
}
示例12: compress
/**
* Static method to compress data
*
* @param string $data
* @param int $block
* @return mixed
*/
public static function compress($data, $block = 9)
{
// Compress the file
if (file_exists($data)) {
$fullpath = realpath($data);
$data = file_get_contents($data);
// Create the new Bzip2 file resource, write data and close it
$bzResource = bzopen($fullpath . '.bz2', 'w');
bzwrite($bzResource, $data, strlen($data));
bzclose($bzResource);
return $fullpath . '.bz2';
// Else, compress the string
} else {
return bzcompress($data, $block);
}
}
示例13: bzip2
function bzip2($in, $out)
{
if (!file_exists($in) || !is_readable($in)) {
return false;
}
if (!file_exists($out) && !is_writeable(dirname($out)) || file_exists($out) && !is_writable($out)) {
return false;
}
$in_file = fopen($in, "r");
$out_file = bzopen($out, "w");
while (!feof($in_file)) {
$buffer = fgets($in_file, 4096);
bzwrite($out_file, $buffer, 4096);
}
fclose($in_file);
bzclose($out_file);
return true;
}
示例14: write
function write($data)
{
global $dump, $fp;
if ($_POST['save'] == 0) {
$dump .= $data;
} else {
switch ($_POST['compr']) {
case 0:
fwrite($fp, $data);
break;
case 1:
gzwrite($fp, $data);
break;
case 2:
bzwrite($fp, $data);
break;
}
}
}
示例15: bzip2_compress
function bzip2_compress($src_file, $dest_file = null)
{
if ($dest_file == null) {
$dest_file = $src_file;
}
$content = file_get_contents($src_file);
if (empty($content)) {
return 1;
}
$bz = bzopen($dest_file, "w");
if (!$bz) {
return 2;
}
$ret = bzwrite($bz, $content);
if (!$ret) {
bzclose($bz);
return 3;
}
bzclose($bz);
return 0;
}