Exemplo n.º 1
0
 public function extractTo($extractPath, $files = null)
 {
     $fs = new FileSystem();
     $ds = DIRECTORY_SEPARATOR;
     for ($i = 0; $i < $this->numFiles; $i++) {
         $oldName = parent::getNameIndex($i);
         $newName = mb_convert_encoding($this->getNameIndex($i), 'ISO-8859-1', 'CP850,UTF-8');
         //we cheat a little because we can't tell wich name the extracted part should have
         //so we put it a directory wich share it's name
         $tmpDir = $extractPath . $ds . '__claro_zip_hack_' . $oldName;
         parent::extractTo($tmpDir, parent::getNameIndex($i));
         //now we move the content of the directory and we put the good name on it.
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isFile()) {
                 $fs->mkdir(dirname($extractPath . $ds . $oldName));
                 $fs->rename($item->getPathname(), $extractPath . $ds . $oldName);
             }
         }
     }
     //we remove our 'trash here'
     $iterator = new \DirectoryIterator($extractPath);
     foreach ($iterator as $item) {
         if (strpos($item->getFilename(), '_claro_zip_hack')) {
             $fs->rmdir($item->getRealPath(), true);
         }
     }
 }
Exemplo n.º 2
0
 public function removeInstallationFiles()
 {
     chdir($this->dir_opencart);
     if (is_file($this->dir_opencart . DIRECTORY_SEPARATOR . "config-dist.php")) {
         unlink($this->dir_opencart . DIRECTORY_SEPARATOR . "config-dist.php");
     }
     if (is_file($this->dir_opencart . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . "config-dist.php")) {
         unlink($this->dir_opencart . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . "config-dist.php");
     }
     // remove install folder
     if (is_dir($this->dir_opencart . DIRECTORY_SEPARATOR . "install")) {
         $fsh = new FileSystem();
         $fsh->rmdir($this->dir_opencart . DIRECTORY_SEPARATOR . "install");
     }
 }