diff --git a/includes/file.inc b/includes/file.inc
index 30fd445..57bfd10 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -2072,6 +2072,33 @@ function file_get_mimetype($uri, $mapping = NULL) {
 }
 
 /**
+ * Returns a file object which can be passed to file_save().
+ *
+ * @param $uri
+ *  A string containing the URI, path, or filename.
+ * @return
+ *  A file object, or FALSE on error.
+ */
+function file_uri_to_object($uri) {
+  $uri = file_stream_wrapper_uri_normalize($uri);
+  $files = entity_load('file', FALSE, array('uri' => $uri));
+  $file = !empty($files) ? reset($files) : FALSE;
+  if (!$file) {
+    global $user;
+    $file = new stdClass();
+    $file->uid = $user->uid;
+    $file->filename = basename($uri);
+    $file->uri = $uri;
+    $file->filemime = file_get_mimetype($uri);
+    // This is gagged because some uris will not support it.
+    $file->filesize = @filesize($uri);
+    $file->timestamp = REQUEST_TIME;
+    $file->status = FILE_STATUS_PERMANENT;
+  }
+  return $file;
+}
+
+/**
  * Set the permissions on a file or directory.
  *
  * This function will use the 'file_chmod_directory' and 'file_chmod_file'
