當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::unlink方法代碼示例

本文整理匯總了PHP中Composer\Util\Filesystem::unlink方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::unlink方法的具體用法?PHP Filesystem::unlink怎麽用?PHP Filesystem::unlink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Util\Filesystem的用法示例。


在下文中一共展示了Filesystem::unlink方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteRemovedFiles

 /**
  * Delete, from Rubedo root dir, all files that have been remove since previous package version
  *
  * @param array $removedFiles files list to be removed
  */
 protected function deleteRemovedFiles($removedFiles)
 {
     foreach ($removedFiles as $file) {
         $filePath = $this->rubedoRootDir . '/' . $file;
         if ($file != '' && file_exists($filePath) && is_file($filePath)) {
             if ($this->io->isVerbose()) {
                 $this->io->write(sprintf('removing file %s ', $filePath));
             }
             $this->fileSystem->unlink($filePath);
         }
     }
 }
開發者ID:novactive,項目名稱:rubedo-core-installer,代碼行數:17,代碼來源:CoreInstaller.php

示例2: unInstall

 /**
  * UnInstall the extension given the list of install files
  *
  * @param array $files
  */
 public function unInstall(array $files)
 {
     foreach ($files as $file) {
         $file = $this->rootDir . $file;
         /*
         because of different reasons the file can be already gone.
         example:
         - file got deployed by multiple modules(should only happen with copy force)
         - user did things
         
         when the file is a symlink, but the target is already gone, file_exists returns false
         */
         if (file_exists($file) xor is_link($file)) {
             $this->fileSystem->unlink($file);
             $parentDir = dirname($file);
             while ($this->fileSystem->isDirEmpty($parentDir) && $parentDir !== $this->rootDir) {
                 $this->fileSystem->removeDirectory($parentDir);
                 $parentDir = dirname($parentDir);
             }
         }
     }
 }
開發者ID:Aleksandr-Kachura,項目名稱:magento,代碼行數:27,代碼來源:UnInstallStrategy.php

示例3: unInstall

 /**
  * @param string $source
  * @param string $destination
  */
 public function unInstall($source, $destination)
 {
     $iterator = $this->getIterator($source, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $item) {
         $destinationFile = sprintf("%s/%s", $destination, $iterator->getSubPathName());
         if ($this->exclude->exclude($iterator->getSubPathName())) {
             continue;
         }
         if (!file_exists($destinationFile)) {
             $this->gitIgnore->removeEntry($iterator->getSubPathName());
             continue;
         }
         if ($item->isDir()) {
             //check if there are not other files in this dir
             if ($this->fileSystem->isDirEmpty($destinationFile)) {
                 $this->fileSystem->removeDirectory($destinationFile);
             }
             continue;
         }
         $this->fileSystem->unlink($destinationFile);
         $this->gitIgnore->removeEntry('/' . $iterator->getSubPathName());
     }
     $this->gitIgnore->removeIgnoreDirectories();
 }
開發者ID:hhirsch,項目名稱:magento-core-composer-installer,代碼行數:28,代碼來源:CoreInstaller.php

示例4: testUnlinkSymlinkedDirectory

 /**
  * @link https://github.com/composer/composer/issues/3157
  * @requires function symlink
  */
 public function testUnlinkSymlinkedDirectory()
 {
     $basepath = $this->workingDir;
     $symlinked = $basepath . "/linked";
     @mkdir($basepath . "/real", 0777, true);
     touch($basepath . "/real/FILE");
     $result = @symlink($basepath . "/real", $symlinked);
     if (!$result) {
         $this->markTestSkipped('Symbolic links for directories not supported on this platform');
     }
     if (!is_dir($symlinked)) {
         $this->fail('Precondition assertion failed (is_dir is false on symbolic link to directory).');
     }
     $fs = new Filesystem();
     $result = $fs->unlink($symlinked);
     $this->assertTrue($result);
     $this->assertFalse(file_exists($symlinked));
 }
開發者ID:neon64,項目名稱:composer,代碼行數:22,代碼來源:FilesystemTest.php


注:本文中的Composer\Util\Filesystem::unlink方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。