コード例 #1
0
ファイル: FileTest.php プロジェクト: nextinteractive/utils
 /**
  * @expectedException \BackBee\Utils\Exception\ApplicationException
  */
 public function testExtractZipArchiveExistingDir()
 {
     $zipFile = $this->getFixturesFolder() . 'archive.zip';
     File::extractZipArchive('test', $this->zipPath, true);
 }
コード例 #2
0
 /**
  *
  */
 private function _init()
 {
     if ($this->isInitialised) {
         return;
     }
     if (false === file_exists($this->getConfig('extractedDir'))) {
         $res = mkdir($this->getConfig('extractedDir'), 0777, true);
         if (false === $res) {
             throw new \Exception('Could not create tmp dir: ' . $this->getConfig('extractedDir'));
         }
     }
     $archiveFile = $this->getConfig('archive');
     // if remote file, copy to tmp dir
     if (0 === strpos($archiveFile, 'https://') || 0 === strpos($archiveFile, 'http://') || 0 === strpos($archiveFile, 'ftp://')) {
         $tempFile = tempnam(sys_get_temp_dir(), basename($archiveFile));
         copy($archiveFile, $tempFile);
         $archiveFile = $tempFile;
     }
     File::extractZipArchive($archiveFile, $this->getConfig('extractedDir'), true);
     // delegate to FileSystem connector
     $this->fileSystemConnector = new FileSystem($this->_application, array('basedir' => $this->getConfig('extractedDir')));
     $this->isInitialised = true;
 }