mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-19 17:36:34 +00:00
Improved compression
This commit is contained in:
parent
ab0abfab1c
commit
369f268b90
@ -61,6 +61,10 @@ class ChunkParser{
|
|||||||
public function loadFile($file){
|
public function loadFile($file){
|
||||||
if(ZLIB_EXTENSION === true and file_exists($file.".gz")){
|
if(ZLIB_EXTENSION === true and file_exists($file.".gz")){
|
||||||
$this->raw = gzinflate(file_get_contents($file.".gz"));
|
$this->raw = gzinflate(file_get_contents($file.".gz"));
|
||||||
|
$r = @gzinflate($this->raw);
|
||||||
|
if($r !== false and $r != ""){
|
||||||
|
$this->raw = $r;
|
||||||
|
}
|
||||||
@unlink($file.".gz");
|
@unlink($file.".gz");
|
||||||
file_put_contents($file, $this->raw);
|
file_put_contents($file, $this->raw);
|
||||||
}elseif(!file_exists($file)){
|
}elseif(!file_exists($file)){
|
||||||
@ -166,7 +170,10 @@ class ChunkParser{
|
|||||||
flock($fp, LOCK_UN);
|
flock($fp, LOCK_UN);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
if(ZLIB_EXTENSION === true){
|
if(ZLIB_EXTENSION === true){
|
||||||
file_put_contents($this->file .".gz", gzdeflate(file_get_contents($this->file), 9));
|
$original = filesize($this->file);
|
||||||
|
file_put_contents($this->file .".gz", gzdeflate(gzdeflate(file_get_contents($this->file),9),9)); //Double compression for flat maps
|
||||||
|
$compressed = filesize($this->file .".gz");
|
||||||
|
console("[DEBUG] Saved chunks.dat.gz with ".round(($compressed/$original)*100, 2)."% (".round($compressed/1024, 2)."KB) of the original size", true, true, 2);
|
||||||
if($final === true){
|
if($final === true){
|
||||||
@unlink($this->file);
|
@unlink($this->file);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user