aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-02-04 22:29:57 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-02-04 22:29:57 +0000
commite64bee53ff309472d49666a55457d004cac95d96 (patch)
tree3edd1fa06b4518b72a1c072a84e5ba65e921e0b2 /phpBB/includes/functions_compress.php
parentdb48dd0588178697f8839e546b407d05cc156850 (diff)
downloadforums-e64bee53ff309472d49666a55457d004cac95d96.tar
forums-e64bee53ff309472d49666a55457d004cac95d96.tar.gz
forums-e64bee53ff309472d49666a55457d004cac95d96.tar.bz2
forums-e64bee53ff309472d49666a55457d004cac95d96.tar.xz
forums-e64bee53ff309472d49666a55457d004cac95d96.zip
- Tar extraction and compression has changed to be more efficent by making fewer read/write commands.
git-svn-id: file:///svn/phpbb/trunk@5521 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php23
1 files changed, 5 insertions, 18 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 2d226aefa2..165de43e0c 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -75,7 +75,7 @@ class compress
function add_custom_file($src, $filename)
{
- $this->data($filename, implode('', file($src)), false, stat($src));
+ $this->data($filename, file_get_contents($src), false, stat($src));
return true;
}
@@ -468,15 +468,7 @@ class compress_tar extends compress
@chmod("$dst$filename", 0777);
// Grab the file contents
- $n = floor($filesize / 512);
- for ($i = 0; $i < $n; $i++)
- {
- fwrite($fp, $fzread($this->fp, 512), 512);
- }
- if (($filesize % 512) > 0)
- {
- fwrite($fp, $fzread($this->fp, 512), ($filesize % 512));
- }
+ fwrite($fp, $fzread($this->fp, $filesize + 512 - $filesize % 512), $filesize);
fclose($fp);
}
}
@@ -525,10 +517,9 @@ class compress_tar extends compress
// Checksum
$checksum = 0;
- for ($i = 0; $i < 512; $i++)
+ for ($i = 0; $i < 329; $i++)
{
- $b = unpack("c1char", substr($header, $i, 1));
- $checksum += $b['char'];
+ $checksum += ord(substr($header, $i, 1));
}
$header = substr_replace($header, pack("a8", sprintf("%07o", $checksum)), 148, 8);
@@ -536,12 +527,8 @@ class compress_tar extends compress
if ($stat[7] !== 0 && !$is_dir)
{
- $fzwrite($this->fp, $data);
+ $fzwrite($this->fp, pack('a'.($stat[7] + 512 - $stat[7] % 512), $data));
unset($data);
- if ($stat[7] % 512 > 0)
- {
- $fzwrite($this->fp, str_repeat("\0", 512 - $stat[7] % 512));
- }
}
}