From 3a222b6d435f8720c2c0fa9932862c0e6434b0c2 Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 26 Oct 2005 07:31:09 +0000 Subject: use GLib functions to extract URIs if available. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@687 ee746299-78ed-0310-b773-934348b2243d --- libsylph/utils.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'libsylph') diff --git a/libsylph/utils.c b/libsylph/utils.c index 80b6545c..95bc237f 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -1449,9 +1449,27 @@ gchar *trim_string_before(const gchar *str, gint len) GList *uri_list_extract_filenames(const gchar *uri_list) { GList *result = NULL; - const gchar *p, *q; gchar *file; +#if GLIB_CHECK_VERSION(2, 6, 0) + gchar **uris; + gint i; + + uris = g_uri_list_extract_uris(uri_list); + g_return_val_if_fail(uris != NULL, NULL); + + for (i = 0; uris[i] != NULL; i++) { + file = g_filename_from_uri(uris[i], NULL, NULL); + if (file) + result = g_list_append(result, file); + } + + g_strfreev(uris); + + return result; +#else + const gchar *p, *q; + p = uri_list; while (p) { @@ -1471,7 +1489,7 @@ GList *uri_list_extract_filenames(const gchar *uri_list) strncpy(file, p, q - p + 1); file[q - p + 1] = '\0'; decode_uri(file, file); - result = g_list_append(result,file); + result = g_list_append(result, file); } } } @@ -1480,6 +1498,7 @@ GList *uri_list_extract_filenames(const gchar *uri_list) } return result; +#endif } #define HEX_TO_INT(val, hex) \ -- cgit v1.2.3