예제 #1
0
 function addDirectory($zip_path, $path = "", $comment = "", $recursive = true)
 {
     $zip_path = preg_replace('/^\\//', '', $zip_path);
     $zip_path = $this->addTrailingSlash($zip_path);
     $this->deleteDir($zip_path);
     if ($path) {
         $path = realpath($path);
         $files = $this->_listTree($path, $recursive);
         foreach ($files as $file) {
             $entry = new ZipEntry($this);
             $entry->setPath($zip_path . substr($file, strlen($path) + 1));
             $entry->setLocalPath($file);
             $entry->setComment($comment);
             $entry->setType(is_dir($file));
             $this->addEntry($entry);
             $this->buildPath($entry->getPath(), is_dir($file));
         }
         $this->buildPath($zip_path . substr($file, strlen($path) + 1), is_dir($file));
     } else {
         $entry = new ZipEntry($this);
         $entry->setPath($zip_path);
         $entry->setComment($comment);
         $entry->setType(1);
         $this->addEntry($entry);
         $this->buildPath($entry->getPath());
     }
 }