本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
示例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();
}
示例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));
}