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


PHP Filesystem::emptyDirectory方法代码示例

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


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

示例1: download

 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (!$package->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $package->getPrettyName() . ' is missing reference information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $this->filesystem->emptyDirectory($path);
     $urls = $package->getSourceUrls();
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 $url = realpath($url);
             }
             $this->doDownload($package, $path, $url);
             break;
         } catch (\Exception $e) {
             // rethrow phpunit exceptions to avoid hard to debug bug failures
             if ($e instanceof \PHPUnit_Framework_Exception) {
                 throw $e;
             }
             if ($this->io->isDebug()) {
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('    Failed, trying the next URL');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     $this->io->writeError('');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:VcsDownloader.php

示例2: download

 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (!$package->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $package->getPrettyName() . ' is missing reference information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $this->filesystem->emptyDirectory($path);
     $urls = $package->getSourceUrls();
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 // realpath() below will not understand
                 // url that starts with "file://"
                 $needle = 'file://';
                 $isFileProtocol = false;
                 if (0 === strpos($url, $needle)) {
                     $url = substr($url, strlen($needle));
                     $isFileProtocol = true;
                 }
                 // realpath() below will not understand %20 spaces etc.
                 if (false !== strpos($url, '%')) {
                     $url = rawurldecode($url);
                 }
                 $url = realpath($url);
                 if ($isFileProtocol) {
                     $url = $needle . $url;
                 }
             }
             $this->doDownload($package, $path, $url);
             break;
         } catch (\Exception $e) {
             // rethrow phpunit exceptions to avoid hard to debug bug failures
             if ($e instanceof \PHPUnit_Framework_Exception) {
                 throw $e;
             }
             if ($this->io->isDebug()) {
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('    Failed, trying the next URL');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     $this->io->writeError('');
 }
开发者ID:Rudloff,项目名称:composer,代码行数:50,代码来源:VcsDownloader.php

示例3: cleanUp

 /**
  * Clean up previous installation.
  *
  * @since 0.1.0
  *
  * @param Filesystem $filesystem Reference to the Filesystem instance.
  */
 protected function cleanUp(Filesystem $filesystem)
 {
     $composterPath = Paths::getPath('git_composter');
     if (static::$io->isVeryVerbose()) {
         static::$io->write(sprintf(_('Removing previous PHP Composter actions at %1$s'), $composterPath), true);
     }
     $filesystem->emptyDirectory($composterPath, true);
     $composterTemplate = Paths::getPath('root_template');
     if (static::$io->isVeryVerbose()) {
         static::$io->write(sprintf(_('Removing previous PHP Composter code at %1$s'), $composterTemplate), true);
     }
     $filesystem->emptyDirectory($composterTemplate, true);
 }
开发者ID:php-composter,项目名称:php-composter,代码行数:20,代码来源:Plugin.php


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