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


PHP PharData::count方法代码示例

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


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

示例1: onNewFile

 public function onNewFile(array $info)
 {
     parent::onNewFile($info);
     $files = [];
     switch ($info['fileMimeType']) {
         case 'application/x-gzip':
         case 'application/x-tar':
         case 'application/x-gtar':
             try {
                 $tar = new \PharData($info['filePath']);
             } catch (\UnexpectedValueException $e) {
                 break;
             }
             $this->setNumberOfFiles($tar->count());
             $i = 0;
             foreach ($tar as $file) {
                 $files[] = $file;
                 if ($i >= 1000) {
                     break;
                 }
                 $i++;
             }
             break;
         case 'application/x-zip-compressed':
         case 'application/zip':
         case 'multipart/x-zip':
             $zip = new \ZipArchive();
             $zip->open($info['filePath']);
             $this->setNumberOfFiles($zip->numFiles);
             for ($i = 0; $i < $zip->numFiles && $i < 1000; $i++) {
                 $file = $zip->statIndex($i);
                 $files[] = $file['name'];
             }
             break;
         default:
             throw new \LogicException();
     }
     $this->extraData['files'] = $files;
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:39,代码来源:ArchiveEntity.php

示例2: receiveAction

 /**
  * @param String $action
  * @param Array $httpVars
  * @param Array $fileVars
  * @throws Exception
  */
 public function receiveAction($action, $httpVars, $fileVars)
 {
     //VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !!
     $messages = ConfService::getMessages();
     $repository = ConfService::getRepository();
     $userSelection = new UserSelection($repository, $httpVars);
     $nodes = $userSelection->buildNodes();
     $currentDirPath = AJXP_Utils::safeDirname($userSelection->getUniqueNode()->getPath());
     $currentDirPath = rtrim($currentDirPath, "/") . "/";
     $currentDirUrl = $userSelection->currentBaseUrl() . $currentDirPath;
     if (empty($httpVars["compression_id"])) {
         $compressionId = sha1(rand());
         $httpVars["compression_id"] = $compressionId;
     } else {
         $compressionId = $httpVars["compression_id"];
     }
     $progressCompressionFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressCompressionID-" . $compressionId . ".txt";
     if (empty($httpVars["extraction_id"])) {
         $extractId = sha1(rand());
         $httpVars["extraction_id"] = $extractId;
     } else {
         $extractId = $httpVars["extraction_id"];
     }
     $progressExtractFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressExtractID-" . $extractId . ".txt";
     if ($action == "compression") {
         $archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME);
         $archiveFormat = $httpVars["type_archive"];
         $tabTypeArchive = array(".tar", ".tar.gz", ".tar.bz2");
         $acceptedExtension = false;
         foreach ($tabTypeArchive as $extensionArchive) {
             if ($extensionArchive == $archiveFormat) {
                 $acceptedExtension = true;
                 break;
             }
         }
         if ($acceptedExtension == false) {
             file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.16"]);
             throw new AJXP_Exception($messages["compression.16"]);
         }
         $typeArchive = $httpVars["type_archive"];
         //if we can run in background we do it
         if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
             $archivePath = $currentDirPath . $archiveName;
             file_put_contents($progressCompressionFileName, $messages["compression.5"]);
             AJXP_Controller::applyActionInBackground($repository->getId(), "compression", $httpVars);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $messages["compression.5"], true, 2);
             AJXP_XMLWriter::close();
             return null;
         } else {
             $maxAuthorizedSize = 4294967296;
             $currentDirUrlLength = strlen($currentDirUrl);
             $tabFolders = array();
             $tabAllRecursiveFiles = array();
             $tabFilesNames = array();
             foreach ($nodes as $node) {
                 $nodeUrl = $node->getUrl();
                 if (is_file($nodeUrl) && filesize($nodeUrl) < $maxAuthorizedSize) {
                     array_push($tabAllRecursiveFiles, $nodeUrl);
                     array_push($tabFilesNames, substr($nodeUrl, $currentDirUrlLength));
                 }
                 if (is_dir($nodeUrl)) {
                     array_push($tabFolders, $nodeUrl);
                 }
             }
             //DO A FOREACH OR IT'S GONNA HAVE SOME SAMES FILES NAMES
             foreach ($tabFolders as $value) {
                 $dossiers = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($value));
                 foreach ($dossiers as $file) {
                     if ($file->isDir()) {
                         continue;
                     }
                     array_push($tabAllRecursiveFiles, $file->getPathname());
                     array_push($tabFilesNames, substr($file->getPathname(), $currentDirUrlLength));
                 }
             }
             //WE STOP IF IT'S JUST AN EMPTY FOLDER OR NO FILES
             if (empty($tabFilesNames)) {
                 file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.17"]);
                 throw new AJXP_Exception($messages["compression.17"]);
             }
             try {
                 $tmpArchiveName = tempnam(AJXP_Utils::getAjxpTmpDir(), "tar-compression") . ".tar";
                 $archive = new PharData($tmpArchiveName);
             } catch (Exception $e) {
                 file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage());
                 throw $e;
             }
             $counterCompression = 0;
             //THE TWO ARRAY ARE MERGED FOR THE FOREACH LOOP
             $tabAllFiles = array_combine($tabAllRecursiveFiles, $tabFilesNames);
             foreach ($tabAllFiles as $fullPath => $fileName) {
                 try {
                     $archive->addFile(AJXP_MetaStreamWrapper::getRealFSReference($fullPath), $fileName);
//.........这里部分代码省略.........
开发者ID:Nanomani,项目名称:pydio-core,代码行数:101,代码来源:class.PluginCompression.php

示例3: resume

 /**
  * Resumes the latest database dump.
  *
  * @param Driver   $driver
  * @param int|null $version
  *
  * @return int The version resumed.
  *
  * @throws \RuntimeException
  */
 private function resume(Driver $driver, int $version = null) : int
 {
     if ($version === null) {
         $version = $this->getDumpVersion();
     }
     $this->output->writeln('Resuming at version ' . $version);
     $archivePath = $this->getSqlDumpPath() . '/' . $version . '.tar';
     $phar = new \PharData($archivePath);
     $progress = new ProgressBar($this->output, $phar->count());
     $progress->setMessage('Resuming version');
     $progress->setFormat('%message% [%bar%] %current%/%max% %percent:3s%%');
     $progress->start();
     foreach ($phar as $path => $file) {
         $this->importSqlFile($driver->getPdo(), $path);
         $progress->advance();
     }
     $progress->finish();
     $this->output->writeln('');
     if ($version != $this->getCurrentDatabaseVersion($driver)) {
         throw new \RuntimeException('Error resuming version ' . $version);
     }
     return $version;
 }
开发者ID:dversion,项目名称:dversion,代码行数:33,代码来源:Controller.php


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