diff options
author | Nick Schermer <nick@xfce.org> | 2012-12-08 00:17:15 +0100 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2012-12-08 00:17:15 +0100 |
commit | 4255750cb05bea0e01115fd2a5f91cdff3b1d829 (patch) | |
tree | 92db07abb86c1126c72eaf1b079d7142c93d0489 /tumbler | |
parent | 2165c4239697a905fdd3e46037baa977c05e4fb1 (diff) | |
download | tumbler-4255750cb05bea0e01115fd2a5f91cdff3b1d829.tar.gz |
Drop unneeded vfs schemes.
Skip schemes that cannot be used to generate thumbs. This
removes a load of combinations in the various tables.
Diffstat (limited to 'tumbler')
-rw-r--r-- | tumbler/tumbler-util.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c index cba4e7a..b601364 100644 --- a/tumbler/tumbler-util.c +++ b/tumbler/tumbler-util.c @@ -22,6 +22,10 @@ #include <config.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + #include <glib.h> #include <gio/gio.h> @@ -34,36 +38,38 @@ tumbler_util_get_supported_uri_schemes (void) { const gchar *const *vfs_schemes; gchar **uri_schemes; - gboolean file_scheme_found = FALSE; guint length; - guint n; + guint n = 0; + guint i; GVfs *vfs; /* determine the URI schemes supported by GIO */ vfs = g_vfs_get_default (); vfs_schemes = g_vfs_get_supported_uri_schemes (vfs); - /* search for the "file" scheme */ - for (n = 0; !file_scheme_found && vfs_schemes[n] != NULL; ++n) - if (g_strcmp0 (vfs_schemes[n], "file") == 0) - file_scheme_found = TRUE; - - /* check if the "file" scheme is included */ - if (file_scheme_found) - { - /* it is, so simply copy the array */ - uri_schemes = g_strdupv ((gchar **)vfs_schemes); - } + if (G_LIKELY (vfs_schemes != NULL)) + length = g_strv_length ((gchar **) vfs_schemes); else + length = 0; + + /* always start with file */ + uri_schemes = g_new0 (gchar *, length + 2); + uri_schemes[n++] = g_strdup ("file"); + + if (G_LIKELY (vfs_schemes != NULL)) { - /* it is not, so we need to copy the array and add "file" */ - length = g_strv_length ((gchar **)vfs_schemes); - uri_schemes = g_new0 (gchar *, length + 2); - uri_schemes[0] = g_strdup ("file"); - for (n = 1; n <= length; ++n) - uri_schemes[n] = g_strdup (vfs_schemes[n-1]); - uri_schemes[n] = NULL; + for (i = 0; vfs_schemes[i] != NULL; ++i) + { + /* skip unneeded schemes */ + if (strcmp ("file", vfs_schemes[i]) != 0 + && strcmp ("computer", vfs_schemes[i]) != 0 + && strcmp ("localtest", vfs_schemes[i]) != 0 + && strcmp ("network", vfs_schemes[i]) != 0) + uri_schemes[n++] = g_strdup (vfs_schemes[i]); + } } + uri_schemes[n++] = NULL; + return uri_schemes; } |