/**
  * 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);
         }
     }
 }
 /**
  * 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);
             }
         }
     }
 }
 /**
  * @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();
 }
Beispiel #4
0
 /**
  * @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));
 }