Returns the canonical absolute path of the URI, if possible.

Parameters

string $uri: (optional) The stream wrapper URI to be converted to a canonical absolute path. This may point to a directory or another type of file.

Return value

string|false If $uri is not set, returns the canonical absolute path of the URI previously set by the DrupalStreamWrapperInterface::setUri() function. If $uri is set and valid for this class, returns its canonical absolute path, as determined by the realpath() function. If $uri is set but not valid, returns FALSE.

Overrides DrupalLocalStreamWrapper::getLocalPath

File

includes/stream_wrappers.inc, line 941
Drupal stream wrapper interface.

Class

DrupalPublicStreamWrapper
Drupal public (public://) stream wrapper class.

Code

protected function getLocalPath($uri = NULL) {
  $path = parent::getLocalPath($uri);
  if (variable_get('sa_core_2022_012_override', FALSE)) {
    return $path;
  }
  $private_path = variable_get('file_private_path', FALSE);
  if ($private_path) {
    $private_path = realpath($private_path);
    if ($private_path && strpos($path, $private_path) === 0) {
      return FALSE;
    }
  }
  return $path;
}