BcZip::extract PHP Method

extract() public method

ZIP を展開する
public extract ( $source, $target ) : boolean
$source
$target
return boolean
    public function extract($source, $target)
    {
        $this->error = null;
        $this->topArchiveName = null;
        if ($this->Zip) {
            $result = $this->_extractByPhpLib($source, $target);
        } else {
            $result = $this->_extractByCommand($source, $target);
        }
        if ($result) {
            $extractedPath = $target . $this->topArchiveName;
            $Folder = new Folder();
            $Folder->chmod($extractedPath, 0777);
            return true;
        } else {
            return false;
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * テーマをアップロードして適用する
  */
 public function admin_add()
 {
     $this->pageTitle = 'テーマアップロード';
     $this->subMenuElements = array('themes');
     if ($this->request->data) {
         if (empty($this->request->data['Theme']['file']['tmp_name'])) {
             $this->setMessage('ファイルのアップロードに失敗しました。', true);
         } else {
             $name = $this->request->data['Theme']['file']['name'];
             move_uploaded_file($this->request->data['Theme']['file']['tmp_name'], TMP . $name);
             App::uses('BcZip', 'Lib');
             $BcZip = new BcZip();
             if ($BcZip->extract(TMP . $name, BASER_THEMES)) {
                 $theme = $BcZip->topArchiveName;
                 unlink(TMP . $name);
                 $this->_applyTheme($theme);
                 $this->redirect(array('action' => 'index'));
             } else {
                 $msg = 'アップロードしたZIPファイルの展開に失敗しました。';
                 $msg .= '<br />' . $BcZip->error;
                 $this->setMessage($msg, true);
             }
         }
     }
 }
All Usage Examples Of BcZip::extract