comparison src/m3u/m3u.c @ 2215:9ddfa78b43a0

- now container plugins feed only valid uri to the core. - fix a bug in pls plugin which prevented writing pls playlist.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Fri, 07 Dec 2007 01:13:34 +0900
parents 70b1f1fc4804
children 42a5c9d5830b
comparison
equal deleted inserted replaced
2214:9a869d4bb0d3 2215:9ddfa78b43a0
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 /* #define AUD_DEBUG 1 */
22
21 #include <glib.h> 23 #include <glib.h>
22 #include <string.h> 24 #include <string.h>
23 #include <glib.h> 25 #include <glib.h>
24 #include <glib/gprintf.h> 26 #include <glib/gprintf.h>
25 #include <stdlib.h> 27 #include <stdlib.h>
82 gchar *ext_info = NULL, *ext_title = NULL; 84 gchar *ext_info = NULL, *ext_title = NULL;
83 gsize line_len = 1024; 85 gsize line_len = 1024;
84 gint ext_len = -1; 86 gint ext_len = -1;
85 gboolean is_extm3u = FALSE; 87 gboolean is_extm3u = FALSE;
86 Playlist *playlist = aud_playlist_get_active(); 88 Playlist *playlist = aud_playlist_get_active();
87 gchar *uri; 89 gchar *uri = NULL;
88 90
89 uri = g_filename_to_uri(filename, NULL, NULL); 91 uri = g_filename_to_uri(filename, NULL, NULL);
90 92
91 if ((file = aud_vfs_fopen(uri ? uri : filename, "rb")) == NULL) 93 if ((file = aud_vfs_fopen(uri ? uri : filename, "rb")) == NULL)
92 return; 94 return;
93 95
94 g_free(uri); 96 g_free(uri); uri = NULL;
95 97
96 line = g_malloc(line_len); 98 line = g_malloc(line_len);
97 while (aud_vfs_fgets(line, line_len, file)) { 99 while (aud_vfs_fgets(line, line_len, file)) {
98 while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') { 100 while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') {
99 line_len += 1024; 101 line_len += 1024;
128 parse_extm3u_info(ext_info, &ext_title, &ext_len); 130 parse_extm3u_info(ext_info, &ext_title, &ext_len);
129 g_free(ext_info); 131 g_free(ext_info);
130 ext_info = NULL; 132 ext_info = NULL;
131 } 133 }
132 134
133 uri = g_filename_to_uri(line, NULL, NULL); 135 uri = aud_construct_uri(line, filename);
134 aud_playlist_load_ins_file(playlist, uri ? uri : line, filename, pos, ext_title, ext_len); 136 AUDDBG("uri=%s\n", uri);
137
138 /* add file only if valid uri has been constructed */
139 if (uri) {
140 aud_playlist_load_ins_file(playlist, uri, filename, pos, ext_title, ext_len);
141
142 if (pos >= 0)
143 pos++;
144 }
145
135 g_free(uri); 146 g_free(uri);
136 147
137 aud_str_replace_in(&ext_title, NULL); 148 aud_str_replace_in(&ext_title, NULL);
138 ext_len = -1; 149 ext_len = -1;
139
140 if (pos >= 0)
141 pos++;
142 } 150 }
143 151
144 aud_vfs_fclose(file); 152 aud_vfs_fclose(file);
145 g_free(line); 153 g_free(line);
146 } 154 }