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

Breadcrumb

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

function Platform::getCwd

getcwd() equivalent which always returns a string

Throws

\RuntimeException

19 calls to Platform::getCwd()
Application::doRun in vendor/composer/composer/src/Composer/Console/Application.php
Runs the current application.
ArchiveCommand::archive in vendor/composer/composer/src/Composer/Command/ArchiveCommand.php
ArchiveDownloader::install in vendor/composer/composer/src/Composer/Downloader/ArchiveDownloader.php
@inheritDoc
AutoloadGenerator::dump in vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php
AutoloadGenerator::parseAutoloadsType in vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php

... See full list

File

vendor/composer/composer/src/Composer/Util/Platform.php, line 36

Class

Platform
Platform helper for uniform platform-specific tests.

Namespace

Composer\Util

Code

public static function getCwd(bool $allowEmpty = false) : string {
    $cwd = getcwd();
    // fallback to realpath('') just in case this works but odds are it would break as well if we are in a case where getcwd fails
    if (false === $cwd) {
        $cwd = realpath('');
    }
    // crappy state, assume '' and hopefully relative paths allow things to continue
    if (false === $cwd) {
        if ($allowEmpty) {
            return '';
        }
        throw new \RuntimeException('Could not determine the current working directory');
    }
    return $cwd;
}

API Navigation

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