summaryrefslogtreecommitdiff
path: root/inc/io.php
diff options
context:
space:
mode:
authormarcel <marcel@rucksackreinigung.de>2006-08-23 23:11:49 +0200
committermarcel <marcel@rucksackreinigung.de>2006-08-23 23:11:49 +0200
commitff3ed99f17e6204cc4f6331830c53a084f385d9a (patch)
tree270560469411e93e397f0d64dfafe1a09a7d61e4 /inc/io.php
parent95a12943a8ef44b4c16f72c9c1c7f5e28b1d60c4 (diff)
downloadrpg-ff3ed99f17e6204cc4f6331830c53a084f385d9a.tar.gz
rpg-ff3ed99f17e6204cc4f6331830c53a084f385d9a.tar.bz2
Added bz2 compression support for Attic
darcs-hash:20060823211149-9c1ae-569f295c33dc798a429a373f48cb09122334ea29.gz
Diffstat (limited to 'inc/io.php')
-rw-r--r--inc/io.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/inc/io.php b/inc/io.php
index a71162c11..f9fbbd103 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -91,6 +91,8 @@ function io_readFile($file,$clean=true){
if(@file_exists($file)){
if(substr($file,-3) == '.gz'){
$ret = join('',gzfile($file));
+ }else if(substr($file,-4) == '.bz2'){
+ $ret = bzfile($file);
}else{
$ret = join('',file($file));
}
@@ -101,6 +103,21 @@ function io_readFile($file,$clean=true){
return $ret;
}
}
+/**
+* Returns the content of a .bz2 compressed file as string
+* @author marcel senf <marcel@rucksackreinigung.de>
+*/
+
+function bzfile($file){
+ $bz = bzopen($file,"r");
+ while (!feof($bz)){
+ //8192 seems to be the maximum buffersize?
+ $str = $str . bzread($bz,8192);
+ }
+ bzclose($bz);
+ return $str;
+}
+
/**
* Used to write out a DokuWiki page to file, and send IO_WIKIPAGE_WRITE events.
@@ -144,6 +161,7 @@ function _io_writeWikiPage_action($data) {
* will be appended.
*
* Uses gzip if extension is .gz
+ * and bz2 if extension is .bz2
*
* @author Andreas Gohr <andi@splitbrain.org>
* @return bool true on success
@@ -163,6 +181,14 @@ function io_saveFile($file,$content,$append=false){
}
gzwrite($fh, $content);
gzclose($fh);
+ }else if(substr($file,-4) == '.bz2'){
+ $fh = @bzopen($file,$mode);
+ if(!$fh){
+ msg("Writing $file failed", -1);
+ return false;
+ }
+ bzwrite($fh, $content);
+ bzclose($fh);
}else{
$fh = @fopen($file,$mode);
if(!$fh){