file_stream_wrapper_get_instance_by_uri

Versions
7
file_stream_wrapper_get_instance_by_uri($uri)

Returns a reference to the stream wrapper class responsible for a given URI (stream).

The scheme determines the stream wrapper class that should be used by consulting the stream wrapper registry.

Parameters

$uri A stream, referenced as "scheme://target".

Return value

Returns a new stream wrapper object appropriate for the given URI or FALSE if no registered handler could be found. For example, a URI of "private://example.txt" would return a new private stream wrapper object (DrupalPrivateStreamWrapper).

Related topics

▾ 5 functions call file_stream_wrapper_get_instance_by_uri()

drupal_chmod in includes/file.inc
Set the permissions on a file or directory.
drupal_realpath in includes/file.inc
Returns the absolute path of a file or directory
file_create_url in includes/file.inc
Creates a web-accessible URL for a stream to an external or local file.
file_get_mimetype in includes/file.inc
Determine an Internet Media Type, or MIME type from a filename.
image_gd_save in modules/system/image.gd.inc
GD helper to write an image resource to a destination file.

Code

includes/file.inc, line 242

<?php
function file_stream_wrapper_get_instance_by_uri($uri) {
  $scheme = file_uri_scheme($uri);
  $class = file_stream_wrapper_get_class($scheme);
  if (class_exists($class)) {
    $instance = new $class;
    $instance->setUri($uri);
    return $instance;
  }
  else {
    return FALSE;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.