X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fglocalvfs.c;h=b0bae9cf768c12715953b4a8698d04f88be7c782;hb=51fac05d73f8363de821eb0d6940dedca13a8c0f;hp=8a39f98668801d495a220f86028c7a6c0b24fb26;hpb=3781343738de4abddf56982325a77bd70a98cd26;p=platform%2Fupstream%2Fglib.git diff --git a/gio/glocalvfs.c b/gio/glocalvfs.c index 8a39f98..b0bae9c 100644 --- a/gio/glocalvfs.c +++ b/gio/glocalvfs.c @@ -13,19 +13,24 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: Alexander Larsson */ -#include +#include "config.h" #include "glocalvfs.h" #include "glocalfile.h" +#include "giomodule.h" +#include "giomodule-priv.h" +#include "gvfs.h" #include #include +#ifdef G_OS_UNIX #include +#endif +#include + struct _GLocalVfs { @@ -38,8 +43,13 @@ struct _GLocalVfsClass }; -G_DEFINE_TYPE (GLocalVfs, g_local_vfs, G_TYPE_VFS) - +#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", + 0)) static void g_local_vfs_finalize (GObject *object) { @@ -54,35 +64,50 @@ g_local_vfs_init (GLocalVfs *vfs) /** * g_local_vfs_new: - * - * Returns a new #GVfs handle. + * + * Returns a new #GVfs handle for a local vfs. + * + * Returns: a new #GVfs handle. **/ GVfs * -g_local_vfs_new (void) +_g_local_vfs_new (void) { return g_object_new (G_TYPE_LOCAL_VFS, NULL); } static GFile * -g_local_vfs_get_file_for_path (GVfs *vfs, - const char *path) +g_local_vfs_get_file_for_path (GVfs *vfs, + const char *path) { - return g_local_file_new (path); + return _g_local_file_new (path); } static GFile * -g_local_vfs_get_file_for_uri (GVfs *vfs, - const char *uri) +g_local_vfs_get_file_for_uri (GVfs *vfs, + const char *uri) { 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); + file = _g_local_file_new (path); else - file = g_dummy_file_new (uri); + file = _g_dummy_file_new (uri); g_free (path); @@ -99,15 +124,13 @@ g_local_vfs_get_supported_uri_schemes (GVfs *vfs) static GFile * g_local_vfs_parse_name (GVfs *vfs, - const char *parse_name) + const char *parse_name) { GFile *file; char *filename; - char *user_name; char *user_prefix; const char *user_start, *user_end; char *rest; - struct passwd *passwd_file_entry; g_return_val_if_fail (G_IS_VFS (vfs), NULL); g_return_val_if_fail (parse_name != NULL, NULL); @@ -127,9 +150,13 @@ g_local_vfs_parse_name (GVfs *vfs, user_end = parse_name; if (user_end == user_start) - user_prefix = g_strdup (g_get_home_dir()); + user_prefix = g_strdup (g_get_home_dir ()); else { +#ifdef G_OS_UNIX + struct passwd *passwd_file_entry; + char *user_name; + user_name = g_strndup (user_start, user_end - user_start); passwd_file_entry = getpwnam (user_name); g_free (user_name); @@ -138,6 +165,7 @@ g_local_vfs_parse_name (GVfs *vfs, passwd_file_entry->pw_dir != NULL) user_prefix = g_strdup (passwd_file_entry->pw_dir); else +#endif user_prefix = g_strdup (g_get_home_dir ()); } @@ -156,7 +184,7 @@ g_local_vfs_parse_name (GVfs *vfs, if (filename == NULL) filename = g_strdup (parse_name); - file = g_local_file_new (filename); + file = _g_local_file_new (filename); g_free (filename); return file; @@ -180,9 +208,6 @@ g_local_vfs_class_init (GLocalVfsClass *class) vfs_class = G_VFS_CLASS (class); - vfs_class->name = "local"; - vfs_class->priority = 0; - vfs_class->is_active = g_local_vfs_is_active; vfs_class->get_file_for_path = g_local_vfs_get_file_for_path; vfs_class->get_file_for_uri = g_local_vfs_get_file_for_uri;