Mercurial > audlegacy
comparison src/audacious/playlist.c @ 2978:f4971c7d6384 trunk
Remove inlined urldecoding functions and use g_filename_from_uri() instead where appropriate.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Tue, 03 Jul 2007 21:20:01 -0500 |
parents | 6131bf51ee63 |
children | 83727fbfec54 |
comparison
equal
deleted
inserted
replaced
2977:54081d5cbd76 | 2978:f4971c7d6384 |
---|---|
895 playlist_add_url(Playlist * playlist, const gchar * url) | 895 playlist_add_url(Playlist * playlist, const gchar * url) |
896 { | 896 { |
897 return playlist_ins_url(playlist, url, -1); | 897 return playlist_ins_url(playlist, url, -1); |
898 } | 898 } |
899 | 899 |
900 static gchar * | |
901 _playlist_urldecode_basic_path(const gchar * encoded_path) | |
902 { | |
903 const gchar *cur, *ext; | |
904 gchar *path, *tmp; | |
905 gint realchar; | |
906 | |
907 if (!encoded_path) | |
908 return NULL; | |
909 | |
910 if (!str_has_prefix_nocase(encoded_path, "file:")) | |
911 return NULL; | |
912 | |
913 cur = encoded_path + 5; | |
914 | |
915 if (str_has_prefix_nocase(cur, "//localhost")) | |
916 cur += 11; | |
917 | |
918 if (*cur == '/') | |
919 while (cur[1] == '/') | |
920 cur++; | |
921 | |
922 tmp = g_malloc0(strlen(cur) + 1); | |
923 | |
924 while ((ext = strchr(cur, '%')) != NULL) { | |
925 strncat(tmp, cur, ext - cur); | |
926 ext++; | |
927 cur = ext + 2; | |
928 if (!sscanf(ext, "%2x", &realchar)) { | |
929 /* Assume it is a literal '%'. Several file | |
930 * managers send unencoded file: urls on drag | |
931 * and drop. */ | |
932 realchar = '%'; | |
933 cur -= 2; | |
934 } | |
935 tmp[strlen(tmp)] = realchar; | |
936 } | |
937 | |
938 path = g_strconcat(tmp, cur, NULL); | |
939 g_free(tmp); | |
940 return path; | |
941 } | |
942 | |
943 guint | 900 guint |
944 playlist_ins_dir(Playlist * playlist, const gchar * path, | 901 playlist_ins_dir(Playlist * playlist, const gchar * path, |
945 gint pos, | 902 gint pos, |
946 gboolean background) | 903 gboolean background) |
947 { | 904 { |
948 guint entries = 0; | 905 guint entries = 0; |
949 GList *list, *node; | 906 GList *list, *node; |
950 GHashTable *htab; | 907 GHashTable *htab; |
951 gchar *path2 = _playlist_urldecode_basic_path(path); | 908 gchar *path2 = g_filename_from_uri(path, NULL, NULL); |
952 | 909 |
953 if (path2 == NULL) | 910 if (path2 == NULL) |
954 path2 = g_strdup(path); | 911 path2 = g_strdup(path); |
955 | 912 |
956 htab = g_hash_table_new(devino_hash, devino_compare); | 913 htab = g_hash_table_new(devino_hash, devino_compare); |