diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-07-22 20:06:17 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-07-22 20:06:17 +0000 |
commit | 3c208e1d0b79c0be1e911d93442c154030925f1a (patch) | |
tree | 4f70277375edb088abaefc6878077f65879094f0 /phpBB/includes | |
parent | 2a016e4f47986ff67fece56e1915123a20c995df (diff) | |
download | forums-3c208e1d0b79c0be1e911d93442c154030925f1a.tar forums-3c208e1d0b79c0be1e911d93442c154030925f1a.tar.gz forums-3c208e1d0b79c0be1e911d93442c154030925f1a.tar.bz2 forums-3c208e1d0b79c0be1e911d93442c154030925f1a.tar.xz forums-3c208e1d0b79c0be1e911d93442c154030925f1a.zip |
Save some mem when decompressing .zip
git-svn-id: file:///svn/phpbb/trunk@4315 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/functions_compress.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index b705158d16..e3228577b2 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -161,29 +161,35 @@ class compress_zip extends compress if ($attrib == 0x41FF0010) { - mkdir($dst . $filename); + if (!@mkdir($dst . $filename)) + { + trigger_error("Could not create directory $filename"); + } } else { fseek($this->fp, $offset + 30 + $strlen); // We have to fudge here for time being - - // Read buffer, prepend and append gz file header/footer - $buffer = pack('va1a1Va1a1', 0x8b1f, chr(0x08), chr(0x00), time(), chr(0x00), chr(3)) . fread($this->fp, $c_size) . pack("VV", $crc, $uc_size); - if (!($fp = fopen($dst . $filename . '.gz', 'wb'))) { - die("Could not open temporary $filename.gz"); + trigger_error("Could not open temporary $filename.gz"); } - fwrite($fp, $buffer); + + // .gz header + fwrite($fp, pack('va1a1Va1a1', 0x8b1f, chr(0x08), chr(0x00), time(), chr(0x00), chr(3))); + // data ... write it out in 1KB packets to conserve mem + while ($buffer = fread($this->fp, 1024)) + { + fwrite($fp, $buffer); + } + // .gz footer + fwrite($fp, pack("VV", $crc, $uc_size)); fclose($fp); - unset($buffer); - unset($fp); if (!($fp = fopen($dst . $filename, 'wb'))) { - die("Could not open $filename"); + trigger_error("Could not create $filename"); } if (!($gzfp = gzopen($dst . $filename . '.gz', 'rb'))) @@ -328,7 +334,10 @@ class compress_tar extends compress if ($filetype == 5) { - mkdir($dst . $filename); + if (!@mkdir($dst . $filename)) + { + trigger_error("Could not create directory $filename"); + } continue; } else @@ -338,7 +347,7 @@ class compress_tar extends compress if (!($fp = fopen($dst . $filename, 'wb'))) { - trigger_error('Could not open file for output'); + trigger_error("Could create file $filename"); } $size = 0; |