Commit 034878ce authored by Sean Davis's avatar Sean Davis

Use g_path_dirname instead of own implementation, fix crash with remember playlist (bug 10166)

parent b939f439
......@@ -58,8 +58,6 @@ typedef struct
gchar *g_substr (const gchar* string, gint start, gint end);
gchar *g_char_dirname (const gchar *filename);
static gchar*
parole_filename_to_utf8(const gchar* filename)
{
......@@ -320,27 +318,6 @@ g_substr (const gchar* string,
return g_utf8_strncpy (output, &string[start], len);
}
gchar *
g_char_dirname (const gchar *filename)
{
int index;
const gchar *ptr;
char *find;
gchar *f_name;
f_name = g_strdup(filename);
find = "/";
ptr = strrchr((char *) f_name, find[0]);
if (ptr)
{
index = ptr - f_name;
return g_substr(filename, 0, index);
}
return NULL;
}
static GSList *
parole_pl_parser_parse_m3u (const gchar *filename)
{
......@@ -355,7 +332,7 @@ parole_pl_parser_parse_m3u (const gchar *filename)
guint i;
file = g_file_new_for_path (filename);
path = g_char_dirname(filename);
path = g_path_get_dirname(filename);
if ( !g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) )
goto out;
......@@ -388,27 +365,26 @@ parole_pl_parser_parse_m3u (const gchar *filename)
for ( i = 0; lines[i] != NULL; i++)
{
if ( lines[i][0] == '\0' || lines[i][0] == '#')
continue;
if ( lines[i][0] == '\0' || lines[i][0] == '#')
continue;
if ( lines[i][0] != '/' )
{
pl_filename = g_strjoin("", path, lines[i], NULL);
list = g_slist_append (list, parole_file_new (pl_filename));
}
if ( lines[i][0] == '/' ) {
pl_filename = g_strdup(lines[i]);
}
else {
list = g_slist_append (list, parole_file_new (lines[i]));
}
else {
pl_filename = g_strjoin("", path, lines[i], NULL);
}
list = g_slist_append (list, parole_file_new (pl_filename));
}
if (pl_filename)
g_free(pl_filename);
g_strfreev (lines);
out:
g_object_unref (file);
return list;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment