protected function SystemStreamWrapper::getTarget in System stream wrapper 7
Returns the local writable target of the resource within the stream.
This function should be used in place of calls to realpath() or similar functions when attempting to determine the location of a file. While functions like realpath() may return the location of a read-only file, this method may return a URI or path suitable for writing that is completely separate from the URI used for reading.
Parameters
$uri: Optional URI.
Return value
Returns a string representing a location suitable for writing of a file, or FALSE if unable to write to the file such as with read-only streams.
Overrides DrupalLocalStreamWrapper::getTarget
1 call to SystemStreamWrapper::getTarget()
- SystemStreamWrapper::getExternalUrl in ./
SystemStreamWrapper.inc - Overrides getExternalUrl().
File
- ./
SystemStreamWrapper.inc, line 20
Class
- SystemStreamWrapper
- Drupal system stream wrapper abstract class.
Code
protected function getTarget($uri = NULL) {
if (!isset($uri)) {
$uri = $this->uri;
}
list($scheme, $target) = explode('://', $uri, 2);
// Remove erroneous leading or trailing, forward-slashes and backslashes.
$target = trim($target, '\\/');
// Remove the module/theme/profile name form the file path. This is always
// the first part of the path.
$target = explode('/', $target);
array_shift($target);
$target = implode('/', $target);
// Trim again.
$target = trim($target, '\\/');
return $target;
}