文字

Bzip2 函数

Table of Contents

  • bzclose — 关闭一个 bzip2 文件
  • bzcompress — 把一个字符串压缩成 bzip2 编码数据
  • bzdecompress — 解压经 bzip2 编码过的数据
  • bzerrno — 返回一个 bzip2 错误码
  • bzerror — 返回包含 bzip2 错误号和错误字符串的一个 array
  • bzerrstr — 返回一个 bzip2 的错误字符串
  • bzflush — 强制写入所有写缓冲区的数据
  • bzopen — 打开一个经 bzip2 压缩过的文件
  • bzread — bzip2 文件二进制安全地读取
  • bzwrite — 二进制安全地写入 bzip2 文件

用户评论:

[#1] ec10 at gmx dot net [2004-05-20 11:34:03]

<?php

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"rb");
    
$out_file bzopen ($out"wb");
    
    while (!
feof ($in_file)) {
        
$buffer fgets ($in_file4096);
         
bzwrite ($out_file$buffer4096);
    }

    
fclose ($in_file);
    
bzclose ($out_file);
    
    return 
true;
}


function bunzip2 ($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 bzopen ($in"rb");
    
$out_file fopen ($out"wb");

    while (
$buffer bzread ($in_file4096)) {
        
fwrite ($out_file$buffer4096);
    }
 
    
bzclose ($in_file);
    
fclose ($out_file);
    
    return 
true;
}
?>

上一篇: 下一篇: