コード例 #1
0
 /**
  * Adds a file entry
  *
  * @param   io.archive.zip.ZipFileEntry entry
  * @return  io.archive.zip.ZipFileEntry entry
  * @throws  lang.IllegalArgumentException in case the filename is longer than 65535 bytes
  */
 public function addFile(ZipFileEntry $entry)
 {
     $name = iconv(\xp::ENCODING, $this->unicode ? 'utf-8' : 'cp437', str_replace('\\', '/', $entry->getName()));
     $nameLength = strlen($name);
     if ($nameLength > 0xffff) {
         throw new IllegalArgumentException('Filename too long (' . $nameLength . ')');
     }
     $this->out && $this->out->close();
     if ($this->password) {
         $this->out = new CipheringZipFileOutputStream($this, $entry, $name, new ZipCipher($this->password));
     } else {
         $this->out = new ZipFileOutputStream($this, $entry, $name);
     }
     $entry->os = $this->out;
     return $entry;
 }