Exemplo n.º 1
0
 /**
  * Adds a new entry to the zip. An entry is an instance of the Moxiecode_ZipEntry class.
  *
  * @param Moxiecode_ZipEntry $entry Entry to add to zip file structure.
  */
 function addEntry(&$entry)
 {
     if ($entry) {
         $this->_entries[] =& $entry;
         $this->_entryLookup[$entry->getPath()] =& $entry;
     }
 }
Exemplo n.º 2
0
 /**
  * Opens the zip file for read or write access.
  */
 function open()
 {
     if (!$this->_fp) {
         // Load zip
         if (!file_exists($this->_path)) {
             return;
         }
         $this->_fp = @fopen($this->_path, "rb");
         if ($this->_fp) {
             // Parse local file headers
             while ($header = $this->_readLocalFileHeader()) {
                 /*echo "Local file header:\n";
                 		var_dump($header);*/
                 $entry = new Moxiecode_ZipEntry($this, $header);
                 $this->_entries[] = $entry;
                 $this->_entryLookup[$entry->getPath()] = $entry;
             }
             // Parse central dir headers
             while ($header = $this->_readCentralDirHeader()) {
                 /*echo "Central dir header:\n";
                 		var_dump($header);*/
                 // Append to existing headers
                 for ($i = 0; $i < count($this->_entries); $i++) {
                     $entry = $this->_entries[$i];
                     if ($entry->getPath() == $header['filename']) {
                         $entry->_addHeader($header);
                     }
                 }
             }
             // Parse central dir end header
             if ($header = $this->_readCentralDirEnd()) {
                 /*echo "Central dir end:\n";
                 		var_dump($header);*/
                 $this->_setHeader($header);
             }
         }
     }
 }