当前位置: 首页>>代码示例>>PHP>>正文


PHP PharData::extractTo方法代码示例

本文整理汇总了PHP中PharData::extractTo方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::extractTo方法的具体用法?PHP PharData::extractTo怎么用?PHP PharData::extractTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PharData的用法示例。


在下文中一共展示了PharData::extractTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: diy_compile


//.........这里部分代码省略.........
                    $stmt2 = $storage->prepare('SELECT * FROM oauth_clients WHERE client_id = :device');
                    $stmt2->execute(array('device' => trim($device)));
                    $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
                    if ($row2["apiport"]) {
                        // *************************************** compiler *********************************
                        // srcfile echeis se base64 ton kodika
                        // compiler echeis ton compiler pou thelei o user   mechri stigmis echoume   gcc, ino
                        // filename to filename pou edosse o user
                        // o poros compilesketch
                        // afou kanei compile
                        // epistrefei
                        // error   ta lathi  h noerrors
                        // binfile    to hex file
                        $compilerserver = diyConfig::read("compiler.host");
                        $compilerserver .= ":" . diyConfig::read("compiler.port");
                        $data1 = 'filename=' . $filename;
                        $data1 .= '&compiler=' . $comp;
                        $data1 .= '&srcfile=' . $srcfile;
                        $fixedFiles = array();
                        foreach ($srclib as $curName => $curFile) {
                            $fixedFiles[] = 'srclib[' . $curName . ']=' . $curFile;
                        }
                        $data1 .= '&' . implode('&', $fixedFiles);
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_URL, "{$compilerserver}/api/compilesketch");
                        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
                        curl_setopt($ch, CURLOPT_POST, 1);
                        $or = curl_exec($ch);
                        if (!$or) {
                            $or = curl_error($ch);
                        }
                        $result["compiler"] = $or;
                        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
                        $result["status"] = "200";
                        $r = json_decode($or, true);
                        if (!$r) {
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
                            $result["compiler"] = $or;
                            $result["status"] = "500";
                            return $result;
                        }
                        if ($r['status'] != 200) {
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
                            $result["status"] = "500";
                            return $result;
                        }
                        unset($result["compiler"]);
                        // No need to transfer this to the user
                        //$srcfilebase64encode = base64_encode($srcfile);
                        $apiport = trim($row2["apiport"]);
                        // *************************************** compiler *********************************
                        if ($r['status'] == 200 && $writedevice == "yes") {
                            $apiport = trim($row2["apiport"]);
                            $binfile = $r['hex'];
                            $data1 = 'file=base64';
                            $data1 .= '&binfile=' . $binfile;
                            $ch = curl_init();
                            curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:{$apiport}/api/writesketch");
                            curl_setopt($ch, CURLOPT_TIMEOUT, 90);
                            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
                            curl_setopt($ch, CURLOPT_POST, 1);
                            $r = curl_exec($ch);
                            $result["sketch"] = $r;
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
                            $result["status"] = "200";
                            //$result["result"]=  $r;
                        }
                        // If we are here with no exceptions then everything went well. Lets save the sketch.
                        $ziptmp = tempnam(sys_get_temp_dir(), 'diytmpzip') . '.tgz';
                        file_put_contents($ziptmp, base64_decode($r['zip']));
                        $p = new PharData($ziptmp);
                        $p->decompress();
                        // creates /path/to/my.tar
                        $ziptmpextracted = str_replace('.tgz', '.tar', $ziptmp);
                        $phar = new PharData($ziptmpextracted);
                        $writeDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $filename;
                        $phar->extractTo($sourceWriteDir);
                    }
                } catch (Exception $e) {
                    $diy_error["db"] = $e->getCode();
                    $result["status"] = $e->getCode();
                    $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
                }
            }
        } catch (Exception $e) {
            $diy_error["db"] = $e->getCode();
            $result["status"] = $e->getCode();
            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
        }
    }
    if (diyConfig::read('debug') == 1) {
        $result["debug"] = $diy_error;
    }
    return $result;
}
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:101,代码来源:diy_compiledevices.php

示例2: extract

 /**
  * Load and extract our application development files
  *
  * @return  void
  */
 public static function extract()
 {
     /* Are we IN_DEV (and does it matter)? */
     if (static::$checkInDev) {
         if (!defined('\\IPS\\IN_DEV') or !\IPS\IN_DEV) {
             return;
         }
     }
     /* Attempt to load our application */
     $thisApp = NULL;
     $applications = \IPS\Application::applications();
     foreach ($applications as $application) {
         if ($application->directory === static::$appDir) {
             $thisApp = $application;
         }
     }
     if (!$thisApp) {
         \IPS\Log::i(\LOG_ERR)->write('Error : Application ' . static::$appDir . ' not found', 'devpackager_error');
         return;
     }
     /* Set our paths */
     $appPath = join(\DIRECTORY_SEPARATOR, [\IPS\ROOT_PATH, 'applications', $thisApp->directory]);
     $devPath = join(\DIRECTORY_SEPARATOR, [$appPath, 'dev']);
     $devTar = join(\DIRECTORY_SEPARATOR, [$appPath, 'data', 'dev.tar']);
     /* Load and extract our tarball */
     try {
         if (!is_dir($devPath)) {
             mkdir($devPath, 0777, true);
         }
         $devFiles = new \PharData($devTar, 0, NULL, \Phar::TAR);
         $devFiles->extractTo($devPath, NULL, TRUE);
     } catch (\Exception $e) {
         \IPS\Log::i(\LOG_ERR)->write('Error : ' . $e->getMessage() . "\n" . $e->getTraceAsString(), 'devpackager_error');
     }
 }
开发者ID:alobimday,项目名称:IPS-Faker,代码行数:40,代码来源:DevFiles.php

示例3: extractTo

 /**
  * @inheritDoc
  */
 public function extractTo($dir)
 {
     $phar = new \PharData($this->file);
     $result = $phar->extractTo($dir, null, true);
     $phar = null;
     return $result;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:10,代码来源:PharArchiveReader.php

示例4: getArchivers

 protected function getArchivers($use_cache = true)
 {
     $arcs = array('create' => array(), 'extract' => array());
     $obj = $this;
     // php 5.3 compatibility
     if (class_exists('ZipArchive')) {
         $arcs['extract']['application/zip'] = array('cmd' => function ($archive, $path) use($obj) {
             $zip = new \ZipArchive();
             if ($zip->open($archive)) {
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $stat = $zip->statIndex($i);
                     if (empty($stat['size'])) {
                         // directory
                         continue;
                     }
                     $filename = $stat['name'];
                     if (!$obj->tyghIsUTF8($filename) && function_exists('iconv')) {
                         $newfile = iconv('cp866', 'utf-8', $filename);
                     } else {
                         $newfile = $filename;
                     }
                     $obj->tyghMkdir(dirname($path . '/' . $newfile));
                     copy('zip://' . $archive . '#' . $filename, $path . '/' . $newfile);
                 }
                 $zip->close();
                 return true;
             }
             return false;
         }, 'ext' => 'zip');
         $arcs['create']['application/zip'] = array('cmd' => function ($archive, $files) use($obj) {
             $zip = new \ZipArchive();
             if ($zip->open($archive, \ZipArchive::CREATE) === true) {
                 $base_path = dirname($archive);
                 foreach ($files as $file) {
                     $path = $base_path . DIRECTORY_SEPARATOR . $file;
                     if (is_file($path)) {
                         $zip->addFile($path, $file);
                     } elseif (is_dir($path)) {
                         foreach ($obj->tyghGetFiles($path) as $_file) {
                             $zip->addFile($path . DIRECTORY_SEPARATOR . $_file, $_file);
                         }
                     }
                 }
                 $zip->close();
                 return true;
             }
             return false;
         }, 'ext' => 'zip');
     }
     if (class_exists('PharData')) {
         $arcs['extract']['application/x-gzip'] = array('cmd' => function ($archive, $path) {
             $phar = new \PharData($archive);
             $phar->extractTo($path, null, true);
         }, 'ext' => 'tgz');
     }
     return $arcs;
 }
开发者ID:askzap,项目名称:ultimate,代码行数:57,代码来源:Volume.php

示例5: Parse

 /**
  * Parse a tarball of .gcov files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // Find the data.json file and extract the source directory from it.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "data.json") {
             $jsonContents = file_get_contents($fileinfo->getRealPath());
             $jsonDecoded = json_decode($jsonContents, true);
             if (is_null($jsonDecoded) || !array_key_exists("Source", $jsonDecoded) || !array_key_exists("Binary", $jsonDecoded)) {
                 $this->DeleteDirectory($dirName);
                 return false;
             }
             $this->SourceDirectory = $jsonDecoded['Source'];
             $this->BinaryDirectory = $jsonDecoded['Binary'];
             break;
         }
     }
     if (empty($this->SourceDirectory) || empty($this->BinaryDirectory)) {
         $this->DeleteDirectory($dirName);
         return false;
     }
     // Check if any Labels.json files were included
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "Labels.json") {
             $this->ParseLabelsFile($fileinfo);
         }
     }
     // Recursively search for .gcov files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == "gcov") {
             $this->ParseGcovFile($fileinfo);
         }
     }
     // Insert coverage summary (removing any old results first)
     //$this->CoverageSummary->RemoveAll();
     $this->CoverageSummary->Insert();
     $this->CoverageSummary->ComputeDifference();
     // Delete the directory when we're done.
     $this->DeleteDirectory($dirName);
     return true;
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:59,代码来源:GcovTar_handler.php

示例6: extract

 /**
  * TODO: Is it possible to extract directly from the stream? With stream filters?
  *
  * @param $target
  */
 public function extract($target)
 {
     if (!isset($this->target)) {
         $this->target = sys_get_temp_dir() . '/' . uniqid() . '.tar';
         $this->saveTar($this->target);
         $this->removeTarget = true;
     }
     $phar = new \PharData($this->target);
     $phar->extractTo($target);
 }
开发者ID:jarkt,项目名称:docker-php-client,代码行数:15,代码来源:Files.php

示例7: loadArchive

 /**
  * Загружает и распаковывает данные с ipgeobase.ru
  * 
  * @param string $path Путь до каталога с БД
  * @return boolean
  */
 public function loadArchive($path)
 {
     $path = rtrim($path, '/');
     $tmpfname = '/tmp/' . basename($this->archiveUri);
     copy($this->archiveUri, $tmpfname);
     $phar = new \PharData($tmpfname);
     $phar->extractTo($path, null, true);
     $cities = file_get_contents($path . '/cities.txt');
     file_put_contents($path . '/cities.txt', iconv('WINDOWS-1251', 'UTF-8', $cities));
     return true;
 }
开发者ID:Cimus,项目名称:ipGeoBase,代码行数:17,代码来源:IpGeoBaseUtil.php

示例8: extract

 /**
  * {@inheritdoc}
  */
 public function extract($file, $target, Format\FormatInterface $format)
 {
     $this->checkSupport($format);
     try {
         $archive = new \PharData($file);
         $archive->extractTo($target, null, true);
     } catch (\Exception $e) {
         throw new FileCorruptedException($file);
     }
     return true;
 }
开发者ID:hassiumsoft,项目名称:hasscms-app-vendor,代码行数:14,代码来源:PharData.php

示例9: extract

 public function extract($source, $target)
 {
     try {
         $phar = new PharData($source);
         $phar->extractTo($target, null, true);
         // throws exception
         exec("find " . $target . " -type d -exec chmod 0777 {} +");
         exec("find " . $target . " -type f -exec chmod 0777 {} +");
     } catch (Exception $e) {
     }
 }
开发者ID:wallrio,项目名称:suite,代码行数:11,代码来源:ModelAssistent.php

示例10: extract

 /**
  * {@inheritdoc}
  */
 public function extract($file, $target, Format\FormatInterface $format)
 {
     $this->checkSupport($format);
     try {
         $pharFormat = $this->getPharFormat($format);
         $archive = new \PharData($file);
         $archive->extractTo($target, null, true);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:anthonyhowell,项目名称:distill,代码行数:15,代码来源:PharData.php

示例11: unpack

 /**
  * Unpack PHAR archive
  *
  * @param string $file File path
  * @param string $dir  Dir to extract to
  *
  * @return string
  */
 public static function unpack($file, $dir)
 {
     $dir = \Includes\Utils\FileManager::getCanonicalDir($dir) . pathinfo($file, PATHINFO_FILENAME);
     try {
         $phar = new \PharData($file);
         $result = $phar->extractTo($dir, null, true);
     } catch (\Exception $exception) {
         $result = false;
         \XLite\Upgrade\Logger::getInstance()->logError($exception->getMessage());
     }
     return array($dir, $result);
 }
开发者ID:kingsj,项目名称:core,代码行数:20,代码来源:PHARManager.php

示例12: extract

 public function extract()
 {
     $varDir = $this->rootDir . DIRECTORY_SEPARATOR . 'var';
     $tarFile = $varDir . DIRECTORY_SEPARATOR . 'magento.tar';
     if (file_exists($tarFile)) {
         unlink($tarFile);
     }
     $phar = new \PharData($this->filename);
     $phar->decompress();
     $phar = new \PharData($tarFile);
     $phar->extractTo($varDir, null, true);
 }
开发者ID:arnaud-hours,项目名称:magentofuse,代码行数:12,代码来源:MagentoDownloader.php

示例13: extract

 /**
  * @param string            $path           The path to the archive.
  * @param string            $destination    The directory to extract any contents into.
  * @param null|array|string $files          Any specific file(s) to extract as a string or array,
  *                                          defaults to NULL which extracts everything.
  * @param bool              $allowOverwrite Whether overwrite of any existing files should be allowed
  *                                          during extraction.
  * @param bool              $deleteArchive  Whether the archive should be deleted after successful extraction
  *
  * @throws ExtractionException If extraction failed.
  */
 public function extract($path, $destination, $files = null, $allowOverwrite = false, $deleteArchive = false)
 {
     try {
         $phar = new \PharData($path);
         $phar->extractTo($destination, $files, $allowOverwrite);
     } catch (\Exception $e) {
         throw new ExtractionException(sprintf('Failed to extract contents from archive with path: "%s"', $destination), null, $e);
     }
     if ($deleteArchive === true) {
         unlink($path);
     }
 }
开发者ID:cleentfaar,项目名称:pharly,代码行数:23,代码来源:Pharly.php

示例14: _extract

 private static function _extract($tarball, $dest)
 {
     if (!class_exists('PharData')) {
         $cmd = "tar xz --strip-components=1 --directory=%s -f {$tarball}";
         WP_CLI::launch(Utils\esc_cmd($cmd, $dest));
         return;
     }
     $phar = new PharData($tarball);
     $tempdir = implode(DIRECTORY_SEPARATOR, array(dirname($tarball), basename($tarball, '.tar.gz'), $phar->getFileName()));
     $phar->extractTo(dirname($tempdir), null, true);
     self::_copy_overwrite_files($tempdir, $dest);
     self::_rmdir(dirname($tempdir));
 }
开发者ID:ptahdunbar,项目名称:wp-cli,代码行数:13,代码来源:core.php

示例15: retrieveAndPrintHtml

 protected function retrieveAndPrintHtml($suite)
 {
     $tempFile = str_replace('.', '', tempnam(sys_get_temp_dir(), 'C3')) . '.tar';
     file_put_contents($tempFile, $this->c3Request('html'));
     $destDir = Configuration::outputDir() . $suite . '.remote.coverage';
     if (is_dir($destDir)) {
         FileSystem::doEmptyDir($destDir);
     } else {
         mkdir($destDir, 0777, true);
     }
     $phar = new \PharData($tempFile);
     $phar->extractTo($destDir);
     unlink($tempFile);
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:14,代码来源:RemoteServer.php


注:本文中的PharData::extractTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。