From 82535617d0e3f0a58eac5c70a34763d3116e64d0 Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sun, 4 Aug 2013 00:09:14 +0200 Subject: [PATCH] Implemented possibility to set an archive comment --- .../install/files/lib/system/io/ZipWriter.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php index 39dc4c14d2..997c2f67fc 100644 --- a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php +++ b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php @@ -18,6 +18,7 @@ class ZipWriter { protected $data = array(); protected $endOfData = "\x50\x4b\x05\x06\x00\x00\x00\x00"; protected $lastOffset = 0; + protected $zipComment = ''; /** * Adds a folder to the Zip archive. @@ -151,6 +152,15 @@ class ZipWriter { $this->data[] = $record; } + /** + * Set Zip archive comment + * + * @param string $comment zip archive comment + */ + public function setArchiveComment($comment) { + $this->zipComment = StringUtil::trim($comment); + } + /** * Constructs the final Zip file structure and return it. * @@ -172,7 +182,7 @@ class ZipWriter { pack("v", count($this->data)). pack("V", strlen($data)). pack("V", strlen($headers)). - "\x00\x00"; + (!empty($this->zipComment) ? pack("v", strlen($this->zipComment)) . $this->zipComment : "\x00\x00"); } /** -- 2.20.1