• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PharData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: backupArchive

 /**
  * @param  string $project
  * @return array  $return
  */
 public function backupArchive($project)
 {
     // Exception if not defined
     if (!isset($this->config[$project]['archive'])) {
         throw new \Exception('No "Archive config" for this project', 1);
     }
     // Get backup settings
     $settings = $this->getArchiveSettings($project);
     // Get backup file prefix
     $backupFilePrefix = '';
     if (!empty($settings['backup_file_prefix'])) {
         $backupFilePrefix = $settings['backup_file_prefix'];
     }
     // Set filename
     $filename = $backupFilePrefix . date('Ymd_His') . '.tar';
     // Data required to backup Database
     $path = $this->getBackupPath($project, 'archive');
     // Create Archive
     $phar = new \PharData($path . '/' . $filename);
     $phar->buildFromIterator(new \ArrayIterator($this->getArchiveFilesList($project)));
     // Compress and unlink none compress archive
     $phar->compress(\Phar::GZ);
     unlink($path . '/' . $filename);
     return $this->getBackupInfo($path, $filename);
 }
开发者ID:spotlab,项目名称:safeguard,代码行数:29,代码来源:Guardian.php


示例2: 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


示例3: archive

 /**
  * {@inheritdoc}
  */
 public function archive($sources, $target, $format, array $excludes = array())
 {
     $sources = realpath($sources);
     // Phar would otherwise load the file which we don't want
     if (file_exists($target)) {
         unlink($target);
     }
     try {
         $filename = substr($target, 0, strrpos($target, $format) - 1);
         // Check if compress format
         if (isset(static::$compressFormats[$format])) {
             // Current compress format supported base on tar
             $target = $filename . '.tar';
         }
         $phar = new \PharData($target, null, null, static::$formats[$format]);
         $files = new ArchivableFilesFinder($sources, $excludes);
         $phar->buildFromIterator($files, $sources);
         if (isset(static::$compressFormats[$format])) {
             // Check can be compressed?
             if (!$phar->canCompress(static::$compressFormats[$format])) {
                 throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
             }
             // Delete old tar
             unlink($target);
             // Compress the new tar
             $phar->compress(static::$compressFormats[$format]);
             // Make the correct filename
             $target = $filename . '.' . $format;
         }
         return $target;
     } catch (\UnexpectedValueException $e) {
         $message = sprintf("Could not create archive '%s' from '%s': %s", $target, $sources, $e->getMessage());
         throw new \RuntimeException($message, $e->getCode(), $e);
     }
 }
开发者ID:alcaeus,项目名称:composer,代码行数:38,代码来源:PharArchiver.php


示例4: test_load_extension

 /**
  * @covers common\classes\AutoLoader::load_extension
  */
 public function test_load_extension()
 {
     $extensions = glob(ROOT_PATH . DS . 'extensions' . DS . '*');
     foreach ($extensions as $extension) {
         $name = ucwords(explode('.', basename($extension))[0]);
         self::assertTrue(AutoLoader::load_extension($name));
     }
     self::assertFalse(AutoLoader::load_extension('NotExistedClass'));
     $name = 'fakeextension';
     $extension_file = ROOT_PATH . DS . 'extensions' . DS . $name;
     $extension_build_dir = ROOT_PATH . DS . 'tests' . DS . 'resource' . DS . $name;
     $extension_file_tar = "{$extension_file}.tar";
     $extension_file_gz = "{$extension_file}.tar.gz";
     if (file_exists($extension_file_gz)) {
         Phar::unlinkArchive($extension_file_gz);
     }
     $phar = new PharData($extension_file_tar);
     $phar->buildFromDirectory($extension_build_dir);
     $phar->compress(Phar::GZ);
     if (file_exists($extension_file_tar)) {
         unlink($extension_file_tar);
     }
     self::assertTrue(AutoLoader::load_extension($name));
     unlink($extension_file_gz);
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:28,代码来源:AutoloaderTest.php


示例5: __construct

 /**
  * Files constructor.
  * @param $target
  */
 public function __construct($target)
 {
     $this->tarFilename = sys_get_temp_dir() . '/' . uniqid() . '.tar';
     $phar = new \PharData($this->tarFilename);
     $phar->buildFromDirectory($target);
     $this->tarStream = fopen($this->tarFilename, 'r');
 }
开发者ID:jarkt,项目名称:dockercloud-php-client,代码行数:11,代码来源:Files.php


示例6: copyDirToArchive

 public static function copyDirToArchive($dir, $archive, $basename = null, $excludeDirs = null)
 {
     $dir = rtrim($dir, '/\\');
     $basename = $basename ?: basename($dir);
     rex_dir::create(dirname($archive));
     $files = array();
     $iterator = rex_finder::factory($dir)->recursive()->filesOnly();
     if ($excludeDirs) {
         $iterator->ignoreDirs($excludeDirs, false);
     }
     foreach ($iterator as $path => $file) {
         $subpath = str_replace($dir, $basename, $path);
         $subpath = str_replace('\\', '/', $subpath);
         $files[$subpath] = $path;
     }
     if (class_exists('ZipArchive')) {
         $zip = new ZipArchive();
         $zip->open($archive, ZipArchive::CREATE);
         foreach ($files as $path => $realpath) {
             $zip->addFile($realpath, $path);
         }
         $zip->close();
     } else {
         $phar = new PharData($archive, 0, null, Phar::ZIP);
         $phar->buildFromIterator(new ArrayIterator($files));
         $phar->compressFiles(Phar::GZ);
         foreach ($files as $path => $realpath) {
             if (filesize($realpath) == 0) {
                 $phar[$path]->decompress();
             }
         }
     }
 }
开发者ID:redaxo,项目名称:redaxo4,代码行数:33,代码来源:archive.php


示例7: 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


示例8: create

 /**
  * Create package.
  */
 public function create(array $args = array())
 {
     $archBasename = $this->pkg->getSimpleName() . '-' . $this->pkg->getPrettyVersion();
     /* Work around bug  #67417 [NEW]: ::compress modifies archive basename
        creates temp file and rename it */
     $tempName = getcwd() . '/pkl-tmp.tar';
     if (file_exists($tempName)) {
         unlink($tempName);
     }
     $arch = new \PharData($tempName);
     $pkgDir = $this->pkg->getRootDir();
     foreach ($this->pkg->getFiles() as $file) {
         if (is_file($file)) {
             $name = str_replace($pkgDir, '', $file);
             $arch->addFile($file, $name);
         }
     }
     if (file_exists($tempName)) {
         @unlink($tempName . '.gz');
     }
     $arch->compress(\Phar::GZ);
     unset($arch);
     rename($tempName . '.gz', $archBasename . '.tgz');
     unlink($tempName);
     if ($this->cb) {
         $cb = $this->cb;
         $cb($this->pkg);
     }
 }
开发者ID:staabm,项目名称:pickle,代码行数:32,代码来源:Release.php


示例9: action

 public function action($parent)
 {
     $c = $parent->config;
     $util = new Utility();
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
         $this->r = array('wrong path', 400);
         return;
     }
     $path = $c['current_path'] . $_POST['path'];
     $info = pathinfo($path);
     $base_folder = $c['current_path'] . $util->fix_dirname($_POST['path']) . "/";
     switch ($info['extension']) {
         case "zip":
             $zip = new \ZipArchive();
             if ($zip->open($path) === true) {
                 //make all the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (substr($FullFileName['name'], -1, 1) == "/") {
                         $util->create_folder($base_folder . $FullFileName['name']);
                     }
                 }
                 //unzip into the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (!(substr($FullFileName['name'], -1, 1) == "/")) {
                         $fileinfo = pathinfo($OnlyFileName);
                         if (in_array(strtolower($fileinfo['extension']), $ext)) {
                             copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']);
                         }
                     }
                 }
                 $zip->close();
             } else {
                 $this->r = array('Could not extract. File might be corrupt.', 500);
                 return;
             }
             break;
         case "gz":
             $p = new \PharData($path);
             $p->decompress();
             // creates files.tar
             break;
         case "tar":
             // unarchive from the tar
             $phar = new \PharData($path);
             $phar->decompressFiles();
             $files = array();
             $util->check_files_extensions_on_phar($phar, $files, '', $ext);
             $phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
             break;
         default:
             $this->r = array('This extension is not supported. Valid: zip, gz, tar.', 400);
             return;
             break;
     }
 }
开发者ID:Kingtreemonkey,项目名称:FileManager,代码行数:59,代码来源:Extract.php


示例10: gzipFolder

 static function gzipFolder($folder) {
     try {
         $a = new PharData($folder . '_archive.zip');
         $a->buildFromDirectory($folder);
     } catch (Exception $e) {
         return false;
     } return true;
 }
开发者ID:salatproduction,项目名称:XLSX-2-HTML-SQL-Converter-Standalone,代码行数:8,代码来源:functions.class.php


示例11: __construct

 /**
  * @param string $package path to package file
  */
 function __construct($package, \Pyrus\Package $parent)
 {
     $package = realpath($package);
     if (!$package) {
         throw new Phar\Exception('Phar package ' . $package . ' does not exist');
     }
     $pxml = false;
     $this->archive = $package;
     try {
         if (\Phar::isValidPharFilename($package, 1)) {
             $phar = new \Phar($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
         } else {
             $phar = new \PharData($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             if ($phar->getMetaData()) {
                 $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
             }
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not open Phar archive ' . $package, $e);
     }
     $package = str_replace('\\', '/', $package);
     try {
         if ($pxml === false) {
             $info = pathinfo($package);
             $internal = $info['filename'];
             if (isset($phar[$internal . '/.xmlregistry'])) {
                 if ($phar instanceof \PharData) {
                     $iterate = new \PharData('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 } else {
                     $iterate = new \Phar('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 }
                 foreach (new \RecursiveIteratorIterator($iterate, \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
                     $filename = $file->getFileName();
                     // default to new package.xml
                     if (preg_match('@^(.+)\\-package.xml$@', $filename)) {
                         $pxml = $file->getPathName();
                         break;
                     }
                 }
             } else {
                 foreach (array('package2.xml', $internal . '/' . 'package2.xml', 'package.xml', $internal . '/' . 'package.xml') as $checkfile) {
                     if (isset($phar[$checkfile])) {
                         $this->_BCpackage = true;
                         $pxml = $phar[$checkfile]->getPathName();
                         break;
                     }
                 }
             }
         }
         if ($pxml === false) {
             throw new Phar\Exception('No package.xml in archive');
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not extract Phar archive ' . $package, $e);
     }
     parent::__construct(new \Pyrus\PackageFile($pxml, 'Pyrus\\PackageFile\\v2'), $parent);
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:61,代码来源:Phar.php


示例12: 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


示例13: 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


示例14: imgCreate

 public function imgCreate($tag, $dkFileData)
 {
     file_put_contents('Dockerfile', $dkFileData);
     $dkfiletar = new PharData('Dockerfile.tar');
     $dkfiletar->addFile('Dockerfile');
     //执行此行代码后生成Dockerfile.tar.gz文件
     $dkfiletar->compress(Phar::GZ);
     $this->cmObj->curlPostFile(DOCKER_URL . '/build?t=' . $tag . '&nocache=1', 'Dockerfile.tar.gz', array('Content-Type:application/tar'));
     return $this->cmObj->curlHttpCode();
 }
开发者ID:yonchin,项目名称:Docker-Web,代码行数:10,代码来源:DockerImage.class.php


示例15: 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


示例16: 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


示例17: 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


示例18: run_with_iterator

function run_with_iterator(Iterator $it, $root = '')
{
    $tmpnam = tempnam('/tmp', 'testzip');
    unlink($tmpnam);
    $tmpnam .= '.zip';
    $pd = new PharData($tmpnam);
    var_dump($pd->buildFromIterator($it, $root));
    $z = zip_open($tmpnam);
    while ($entry = zip_read($z)) {
        var_dump([zip_entry_name($entry), zip_entry_filesize($entry)]);
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:create_zip.php


示例19: backupFolder

 /**
  * @param string $folder
  *
  * @return bool
  */
 protected function backupFolder($folder)
 {
     GeneralUtility::mkdir_deep($this->backupPath);
     $compressedFileName = $folder . '_' . time() . '.tar';
     $phar = new \PharData($this->backupPath . $compressedFileName);
     if ($phar->buildFromDirectory(PATH_site . $folder, '/^(?!_temp_|_processed_|_recycler_).*/')) {
         BackupUtility::generateBackupLog($folder, $compressedFileName . '.gz', $this->backupPath, $this->backupsToKeep);
         BackupUtility::gzCompressFile($this->backupPath . $compressedFileName);
         return true;
     }
     return false;
 }
开发者ID:markussom,项目名称:backup_me,代码行数:17,代码来源:BackupCommandController.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Phing类代码示例发布时间:2022-05-23
下一篇:
PHP Phar类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap