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
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Platform.php, line 36
Class
- Platform
- Platform helper for uniform platform-specific tests.
Namespace
Composer\UtilCode
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;
}