#858528: file_uri_target() purpose is unclear.

From: Damien Tournoud <damien@commerceguys.com>


---
 file.inc            |   10 ++++++----
 stream_wrappers.inc |   35 +++++++++++++++--------------------
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git includes/file.inc includes/file.inc
index c4fedfe..70c55bd 100644
--- includes/file.inc
+++ includes/file.inc
@@ -203,7 +203,7 @@ function file_stream_wrapper_valid_scheme($scheme) {
 }
 
 /**
- * Returns the target of a URI (e.g. a stream).
+ * Returns the part of an URI after the schema.
  *
  * @param $uri
  *   A stream, referenced as "scheme://target".
@@ -216,10 +216,12 @@ function file_stream_wrapper_valid_scheme($scheme) {
  * @see file_uri_scheme()
  */
 function file_uri_target($uri) {
-  if ($scheme = file_uri_scheme($uri)) {
-    return file_stream_wrapper_get_instance_by_scheme($scheme)->getTarget($uri);
+  if (($pos = strpos($uri, '://')) !== FALSE) {
+    $target = substr($uri, $pos + 3);
+
+    // Remove erroneous leading or trailing, forward-slashes and backslashes.
+    return trim($target, '\/');
   }
-  return FALSE;
 }
 
 /**
diff --git includes/stream_wrappers.inc includes/stream_wrappers.inc
index 7b92fe0..1338771 100644
--- includes/stream_wrappers.inc
+++ includes/stream_wrappers.inc
@@ -146,24 +146,6 @@ interface DrupalStreamWrapperInterface extends StreamWrapperInterface {
   public function getExternalUrl();
 
   /**
-   * 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.
-   *
-   * @param $uri
-   *   Optional URI.
-   *
-   * @return
-   *   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.
-   */
-  public function getTarget($uri = NULL);
-
-  /**
    * Returns the MIME type of the resource.
    *
    * @param $uri
@@ -286,9 +268,22 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
   }
 
   /**
-   *  Base implementation of getTarget().
+   * 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.
+   *
+   * @param $uri
+   *   Optional URI.
+   *
+   * @return
+   *   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.
    */
-  function getTarget($uri = NULL) {
+  protected function getTarget($uri = NULL) {
     if (!isset($uri)) {
       $uri = $this->uri;
     }
