當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。