Example #1
0
 /**
  * Builds a path inside the zip. This method will be executed by addFile/addDirectory to
  * build a complete structure inside the zip if a file like /a/b/c/d.txt would be added.
  *
  * @param string $path Path inside the zip file to build.
  * @param bool $is_dir Optional is it a directory or an file defaults to false.
  */
 function buildPath($path, $is_dir = false)
 {
     $pos = strrpos($path, '/');
     if ($pos === false) {
         return;
     }
     $path = substr($path, 0, $pos);
     // Check for dir
     $entry =& $this->getEntryByPath($path);
     if ($entry) {
         return;
     }
     // Dir not found create all parents
     $items = explode('/', $path);
     $path = "";
     if ($is_dir) {
         array_pop($items);
     }
     foreach ($items as $item) {
         $path .= $item . '/';
         // Look for entry
         $entry =& $this->getEntryByPath($path);
         if (!$entry) {
             $entry = new Moxiecode_ZipEntry($this);
             $entry->setPath($path);
             $this->addEntry($entry);
         }
     }
 }