Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Filesystem.php

function Filesystem::rmdir

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::rmdir()

Attempts to rmdir a file and in case of failure retries after 350ms on windows

Return value

bool

Throws

\RuntimeException

2 calls to Filesystem::rmdir()
Filesystem::removeDirectoryPhp in vendor/composer/composer/src/Composer/Util/Filesystem.php
Recursively delete directory using PHP iterators.
Filesystem::removeJunction in vendor/composer/composer/src/Composer/Util/Filesystem.php
Removes a Windows NTFS junction.

File

vendor/composer/composer/src/Composer/Util/Filesystem.php, line 316

Class

Filesystem
@author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>

Namespace

Composer\Util

Code

public function rmdir(string $path) {
    $deleted = @rmdir($path);
    if (!$deleted) {
        // retry after a bit on windows since it tends to be touchy with mass removals
        if (Platform::isWindows()) {
            usleep(350000);
            $deleted = @rmdir($path);
        }
        if (!$deleted) {
            $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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal