note 42539 added to ref.bzip2

From: Date: Thu, 20 May 2004 15:34:03 +0000
Subject: note 42539 added to ref.bzip2
Groups: php.notes 
Request: Send a blank email to php-notes+get-69879@lists.php.net to get a copy of this message
/** * @return bool * @param string $in * @param string $out * @desc compressing the file with the bzip2-extension */ 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_file, 4096); bzwrite ($out_file, $buffer, 4096); } fclose ($in_file); bzclose ($out_file); return true; } /** * @return bool * @param string $in * @param string $out * @desc uncompressing the file with the bzip2-extension */ 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_file, 4096)) { fwrite ($out_file, $buffer, 4096); } bzclose ($in_file); fclose ($out_file); return true; } ---- Manual Page -- http://www.php.net/manual/en/ref.bzip2.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42539 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42539&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42539&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69879) next »