Implemented possibility to set an archive comment
authorSascha Greuel <sascha@softcreatr.de>
Sat, 3 Aug 2013 22:09:14 +0000 (00:09 +0200)
committerSascha Greuel <sascha@softcreatr.de>
Sat, 3 Aug 2013 22:09:14 +0000 (00:09 +0200)
wcfsetup/install/files/lib/system/io/ZipWriter.class.php

index 39dc4c14d283b102ba5b9cc073f8440fd1976bbf..997c2f67fcff6d2c4f5249f1849a70b28a2ae122 100644 (file)
@@ -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");
        }
        
        /**