/** * Instantiate an archive adapter object * * @param \Pop\Archive\Archive $archive * @return Zip */ public function __construct(\Pop\Archive\Archive $archive) { if (strpos($archive->getFullpath(), '/.') !== false) { $this->workingDir = substr($archive->getFullpath(), 0, strpos($archive->getFullpath(), '/.')); } else { if (strpos($archive->getFullpath(), '\\.') !== false) { $this->workingDir = substr($archive->getFullpath(), 0, strpos($archive->getFullpath(), '\\.')); } else { $this->workingDir = getcwd(); } } if (substr($archive->getFullpath(), 0, 1) != '/' && substr($archive->getFullpath(), 1, 1) != ':') { $this->path = $this->workingDir . DIRECTORY_SEPARATOR . $archive->getFullpath(); } else { $this->path = realpath(dirname($archive->getFullpath())) . DIRECTORY_SEPARATOR . $archive->getBasename(); } $this->archive = new \ZipArchive(); }
/** * Instantiate an archive adapter object * * @param \Pop\Archive\Archive $archive * @param string $password * @throws Exception * @return Rar */ public function __construct(\Pop\Archive\Archive $archive, $password = null) { $this->path = $archive->getFullpath(); $this->password = $password; if (file_exists($this->path)) { $this->archive = \RarArchive::open($this->path, $this->password); } else { throw new Exception('Due to licensing restrictions, RAR files cannot be created and can only be extracted.'); } }
/** * Method to instantiate an archive adapter object * * @param \Pop\Archive\Archive $archive * @return \Pop\Archive\Adapter\Tar */ public function __construct(\Pop\Archive\Archive $archive) { if (stripos($archive->getExt(), 'bz') !== false) { $this->compression = 'bz'; } else { if (stripos($archive->getExt(), 'gz') !== false) { $this->compression = 'gz'; } } $this->path = $archive->getFullpath(); $this->archive = new \Archive_Tar($this->path); }
/** * Method to instantiate an archive adapter object * * @param \Pop\Archive\Archive $archive * @return \Pop\Archive\Adapter\Phar */ public function __construct(\Pop\Archive\Archive $archive) { $this->path = $archive->getFullpath(); $this->archive = new \Phar($this->path); }