Bug 621213 – GDBusProxy and well-known names
[platform/upstream/glib.git] / gio / glocalvfs.c
index 6e78e74..cd535e3 100644 (file)
 #include "glocalvfs.h"
 #include "glocalfile.h"
 #include "giomodule.h"
+#include "giomodule-priv.h"
 #include "gvfs.h"
 #include <gio/gdummyfile.h>
 #include <sys/types.h>
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
+#include <string.h>
 
 #include "gioalias.h"
 
@@ -46,6 +48,7 @@ struct _GLocalVfsClass
 
 #define g_local_vfs_get_type _g_local_vfs_get_type
 G_DEFINE_TYPE_WITH_CODE (GLocalVfs, g_local_vfs, G_TYPE_VFS,
+                        _g_io_modules_ensure_extension_points_registered ();
                         g_io_extension_point_implement (G_VFS_EXTENSION_POINT_NAME,
                                                         g_define_type_id,
                                                         "local",
@@ -88,9 +91,22 @@ g_local_vfs_get_file_for_uri (GVfs       *vfs,
 {
   char *path;
   GFile *file;
+  char *stripped_uri, *hash;
+  
+  if (strchr (uri, '#') != NULL)
+    {
+      stripped_uri = g_strdup (uri);
+      hash = strchr (stripped_uri, '#');
+      *hash = 0;
+    }
+  else
+    stripped_uri = (char *)uri;
+      
+  path = g_filename_from_uri (stripped_uri, NULL, NULL);
 
-  path = g_filename_from_uri (uri, NULL, NULL);
-
+  if (stripped_uri != uri)
+    g_free (stripped_uri);
+  
   if (path != NULL)
     file = _g_local_file_new (path);
   else