public function FileSystem::realpath in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::realpath()
Resolves the absolute filepath of a local URI or filepath.
The use of this method is discouraged, because it does not work for remote URIs. Except in rare cases, URIs should not be manually resolved.
Only use this function if you know that the stream wrapper in the URI uses the local file system, and you need to pass an absolute path to a function that is incompatible with stream URIs.
Parameters
string $uri: A stream wrapper URI or a filepath, possibly including one or more symbolic links.
Return value
string|false The absolute local filepath (with no symbolic links) or FALSE on failure.
Overrides FileSystemInterface::realpath
See also
\Drupal\Core\StreamWrapper\StreamWrapperInterface::realpath()
http://php.net/manual/function.realpath.php
4 calls to FileSystem::realpath()
- FileSystem::copy in core/
lib/ Drupal/ Core/ File/ FileSystem.php - Copies a file to a new location without invoking the file API.
- FileSystem::move in core/
lib/ Drupal/ Core/ File/ FileSystem.php - Moves a file to a new location without database changes or hook invocation.
- FileSystem::moveUploadedFile in core/
lib/ Drupal/ Core/ File/ FileSystem.php - Moves an uploaded file to a new location.
- FileSystem::prepareDestination in core/
lib/ Drupal/ Core/ File/ FileSystem.php - Prepares the destination for a file copy or move operation.
File
- core/
lib/ Drupal/ Core/ File/ FileSystem.php, line 131
Class
- FileSystem
- Provides helpers to operate on files and stream wrappers.
Namespace
Drupal\Core\FileCode
public function realpath($uri) {
// If this URI is a stream, pass it off to the appropriate stream wrapper.
// Otherwise, attempt PHP's realpath. This allows use of this method even
// for unmanaged files outside of the stream wrapper interface.
if ($wrapper = $this->streamWrapperManager
->getViaUri($uri)) {
return $wrapper
->realpath();
}
return realpath($uri);
}