function Filesystem::unlink
Same name in this branch
- 11.1.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::unlink()
Attempts to unlink a file and in case of failure retries after 350ms on windows
Return value
bool
Throws
\RuntimeException
5 calls to Filesystem::unlink()
- Filesystem::copyThenRemove in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php - Copy then delete is a non-atomic version of {@link rename}.
- Filesystem::emptyDirectory in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php - Filesystem::remove in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php - Filesystem::removeDirectoryPhp in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php - Recursively delete directory using PHP iterators.
- Filesystem::unlinkSymlinkedDirectory in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php, line 286
Class
- Filesystem
- @author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>
Namespace
Composer\UtilCode
public function unlink(string $path) {
$unlinked = @$this->unlinkImplementation($path);
if (!$unlinked) {
// retry after a bit on windows since it tends to be touchy with mass removals
if (Platform::isWindows()) {
usleep(350000);
$unlinked = @$this->unlinkImplementation($path);
}
if (!$unlinked) {
$error = error_get_last();
$message = 'Could not delete ' . $path . ': ' . ($error['message'] ?? '');
if (Platform::isWindows()) {
$message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
}
throw new \RuntimeException($message);
}
}
return true;
}