diff options
author | Patrick Brown <ptbrown@whoopdedo.org> | 2015-05-06 18:21:17 -0400 |
---|---|---|
committer | Patrick Brown <ptbrown@whoopdedo.org> | 2015-05-06 18:21:17 -0400 |
commit | 369075828e13e37a65a2f8062a74e89f98dd3fac (patch) | |
tree | f8d3b4efc8d2ce8ee75ec65944b3f6002d106925 /inc/io.php | |
parent | dfe7cc3f3bfbfccec6a38a94ac0f2242e8bc59e7 (diff) | |
download | rpg-369075828e13e37a65a2f8062a74e89f98dd3fac.tar.gz rpg-369075828e13e37a65a2f8062a74e89f98dd3fac.tar.bz2 |
Append to BZip2 files. Unit tests for writing files.
Diffstat (limited to 'inc/io.php')
-rw-r--r-- | inc/io.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/inc/io.php b/inc/io.php index 0636a4b62..8846b7e56 100644 --- a/inc/io.php +++ b/inc/io.php @@ -223,7 +223,16 @@ function io_saveFile($file,$content,$append=false){ gzwrite($fh, $content); gzclose($fh); }else if(substr($file,-4) == '.bz2'){ - $fh = @bzopen($file,$mode{0}); + if($append) { + $bzcontent = bzfile($file); + if($bzcontent === false) { + msg("Writing $file failed", -1); + io_unlock($file); + return false; + } + $content = $bzcontent.$content; + } + $fh = @bzopen($file,'w'); if(!$fh){ msg("Writing $file failed", -1); io_unlock($file); |