GNOME Bugzilla – Bug 596867
g_vfs_get_supported_uri_schemes doesn't include the "file" uri-scheme
Last modified: 2009-10-01 08:39:45 UTC
As illustrated in this gdb session g_vfs_get_supported_uri_schemes doesn't include the "file" uri-scheme: (This is on Debian testing, Version 1.4.0-1) 124 types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); (gdb) print uri_schemes $1 = (const gchar * const *) 0xb7f53653 (gdb) print uri_schemes[0] $2 = (const gchar * const) 0x1ba <Address 0x1ba out of bounds> (gdb) print (char*) uri_schemes $3 = 0xb7f53653 "\272\1" (gdb) next 121 uri_schemes = g_vfs_get_supported_uri_schemes (vfs); (gdb) 124 types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); (gdb) print (char*) uri_schemes $4 = 0x8065448 "\310\65\6\b\20\32\6\bp7\6\b\250P\6\b\360P\6\b8Q\6\b\220Q\6\b\300Q\6\b\370Q\6\b@R\6\b\210R\6\b\320R\6\b\30S\6\b`S\6\b\250S\6\b\360S\6\b8T\6\b\220U\6\b\20V\6\b" (gdb) print uri_schemes[0] $5 = (const gchar * const) 0x80635c8 "smb" (gdb) print uri_schemes[1] $6 = (const gchar * const) 0x8061a10 "archive" (gdb) print uri_schemes[2] $7 = (const gchar * const) 0x8063770 "trash" (gdb) print uri_schemes[3] $8 = (const gchar * const) 0x80650a8 "obex" (gdb) print uri_schemes[4] $9 = (const gchar * const) 0x80650f0 "ftp" (gdb) print uri_schemes[5] $10 = (const gchar * const) 0x8065138 "cdda" (gdb) print uri_schemes[6] $11 = (const gchar * const) 0x8065190 "sftp" (gdb) print uri_schemes[7] $12 = (const gchar * const) 0x80651c0 "ssh" (gdb) print uri_schemes[8] $13 = (const gchar * const) 0x80651f8 "network" (gdb) print uri_schemes[9] $14 = (const gchar * const) 0x8065240 "burn" (gdb) print uri_schemes[10] $15 = (const gchar * const) 0x8065288 "computer" (gdb) print uri_schemes[11] $16 = (const gchar * const) 0x80652d0 "davs" (gdb) print uri_schemes[12] $17 = (const gchar * const) 0x8065318 "dav" (gdb) print uri_schemes[13] $18 = (const gchar * const) 0x8065360 "davs+sd" (gdb) print uri_schemes[14] $19 = (const gchar * const) 0x80653a8 "dav+sd" (gdb) print uri_schemes[15] $20 = (const gchar * const) 0x80653f0 "gphoto2" (gdb) print uri_schemes[16] $21 = (const gchar * const) 0x8065438 "localtest" (gdb) print uri_schemes[17] $22 = (const gchar * const) 0x8065590 "http" (gdb) print uri_schemes[18] $23 = (const gchar * const) 0x8065610 "dns-sd" (gdb) print uri_schemes[19] $24 = (const gchar * const) 0x0 (gdb)
fixed in git
That's not a bug, gvfs doesn't support file:, gio does...
Although he has a point, I'm not sure if I agree with Bastien here. In that case we should have an API at the level of GIO perhaps? It's not really great for developer productivity to have an API that gives a result that ain't obvious and that requires that app devs check and manually add the "file" uri scheme (which is most likely the result that they wanted). Anyway, Alex had Bug# 574953 for this already apparently. So I'll mark this one as a duplicate of that one. *** This bug has been marked as a duplicate of bug 574953 ***
Well, file is supposed to be always supported. Not very useful API anyway, given that you need to get the vfs module yourself.
If there was a function to query all active GVfs implementations (seems like this will always be default + local) for their supported URI schemes and merge those into a unique array I'd expect this to be part of the GIO API (e.g. in GFile) rather than GVfs. The problem is that even though gvfs has now been fixed, older versions of it will still return an array without the "file" scheme included. This in turn means that people will always have to check for "file" and add it if necessary, because there doesn't seem to be a way to check which version of GVfs is being used at runtime. So, I guess some kind of meta-GVfs function for this information could be interesting.
If you expected to see file: listed as supported by the default GVfs extension (the one in gvfs for us), then your code would be wrong. The file: scheme is always supported and built into GIO. It might be easier if file was listed in the output of this function, but certainly not correct.
Yes, I'm full aware of that. That's why I'm suggesting a function like gchar **g_file_get_supported_uri_schemes (void) which merges the URI scheme arrays returned from g_vfs_get_supported_uri_schemes (g_vfs_get_local ()) and g_vfs_get_supported_uri_schemes (g_vfs_get_default ()) into single unique array. It's just an idea for a more convenient way to query ALL supported URIs from GIO. I know several applications that need something like this and for which it would be convenient to have them returned from GIO in a single array.
bastien: I don't understand why you think the gvfs vfs implementation should not claim to support files, it clearly does. I mean, part of the implementation of this is done by chaining to the local gvfs implementation, but there is also explicit local path handling code in the gvfs GVfsDaemon implementation. Nobody expects g_vfs_get_supported_uri_schemes (g_vfs_get_default ()) to sometimes return "file" and sometimes not just because in some cases it also supports other methods. Arguing about technicallities about where its implemented is just bogus, the GVfs object returned by g_vfs_get_default() *does* in fact handle file uris, as can easily be proven by passing one to it. Anyway, i agree with Jannis that its unfortunate that we had this bug before (its fixed in git now), but there isn't really much we can do about that. Adding a new function that only exists in later, already fixed, versions does not help.