35 const char * slash = strrchr (filename,
'/');
37 return (slash ==
NULL) ? filename : slash + 1;
52 ret = (string_b ==
NULL) ? 0 : -1;
53 else if (string_b ==
NULL)
73 return (int_a < int_b) ? -1 : (int_a > int_b);
173 int (* compare) (
const char *
a,
const char *
b) =
179 for (count = 1; count < entries; count ++)
183 if (compare (last, current) == 0)
194 int (* compare) (
const Tuple *
a,
const Tuple *
b) =
200 for (count = 1; count < entries; count ++)
204 if (last !=
NULL && current !=
NULL && compare (last, current) == 0)
226 for (count = 0; count < entries; count ++)
231 if (! strncmp (filename,
"file://", 7) && !
vfs_file_test (filename,
251 for (field = 0; field < G_N_ELEMENTS (fields); field ++)
256 if (! pattern || ! pattern[0] || regcomp (& regex, pattern, REG_ICASE))
262 for (entry = 0; entry < entries; entry ++)
270 if (!
string || regexec (& regex,
string, 0,
NULL, 0))
288 return g_strdup_printf (
"%s/playlist_%02d.xspf",
297 for (count = 0; ; count ++)
301 if (! g_file_test (path, G_FILE_TEST_EXISTS))
321 g_file_get_contents (order_path, & order_string,
NULL,
NULL);
327 char * * order = g_strsplit (order_string,
" ", -1);
328 g_free (order_string);
330 for (
int i = 0; order[i]; i ++)
334 if (! g_file_test (path, G_FILE_TEST_EXISTS))
346 if (g_str_has_suffix (path,
".xspf"))
369 char * * order = g_malloc (
sizeof (
char *) * (lists + 1));
370 GHashTable * saved = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
NULL);
372 for (
int i = 0; i < lists; i ++)
375 order[i] = g_strdup_printf (
"%d",
id);
379 char * path = g_strdup_printf (
"%s/%d.audpl", folder,
id);
389 g_hash_table_insert (saved, g_strdup_printf (
"%d.audpl",
id),
NULL);
393 char * order_string = g_strjoinv (
" ", order);
399 char * old_order_string;
400 g_file_get_contents (order_path, & old_order_string,
NULL,
NULL);
402 if (! old_order_string || strcmp (old_order_string, order_string))
404 if (! g_file_set_contents (order_path, order_string, -1, & error))
406 fprintf (stderr,
"Cannot write to %s: %s\n", order_path, error->message);
407 g_error_free (error);
411 g_free (order_string);
413 g_free (old_order_string);
421 DIR * dir = opendir (folder);
425 struct dirent *
entry;
426 while ((entry = readdir (dir)))
428 if (! g_str_has_suffix (entry->d_name,
".audpl")
429 && ! g_str_has_suffix (entry->d_name,
".xspf"))
432 if (! g_hash_table_lookup_extended (saved, entry->d_name,
NULL,
NULL))
434 char * path = g_strdup_printf (
"%s/%s", folder, entry->d_name);
443 g_hash_table_destroy (saved);