37 const char * slash = strrchr (filename,
'/');
39 return (slash ==
NULL) ? filename : slash + 1;
54 ret = (string_b ==
NULL) ? 0 : -1;
55 else if (string_b ==
NULL)
75 return (int_a < int_b) ? -1 : (int_a > int_b);
167 int (* compare) (
const char *
a,
const char *
b) =
173 for (count = 1; count < entries; count ++)
177 if (compare (last, current) == 0)
188 int (* compare) (
const Tuple *
a,
const Tuple *
b) =
194 for (count = 1; count < entries; count ++)
198 if (last !=
NULL && current !=
NULL && compare (last, current) == 0)
220 for (count = 0; count < entries; count ++)
225 if (! strncmp (filename,
"file://", 7) && !
vfs_file_test (filename,
245 for (field = 0; field < G_N_ELEMENTS (fields); field ++)
250 if (! pattern || ! pattern[0] || regcomp (& regex, pattern, REG_ICASE))
256 for (entry = 0; entry < entries; entry ++)
264 if (!
string || regexec (& regex,
string, 0,
NULL, 0))
282 return g_strdup_printf (
"%s/playlist_%02d.xspf",
291 for (count = 0; ; count ++)
295 if (! g_file_test (path, G_FILE_TEST_EXISTS))
315 g_file_get_contents (order_path, & order_string,
NULL,
NULL);
321 char * * order = g_strsplit (order_string,
" ", -1);
322 g_free (order_string);
324 for (
int i = 0; order[i]; i ++)
328 if (! g_file_test (path, G_FILE_TEST_EXISTS))
340 if (g_str_has_suffix (path,
".xspf"))
363 char * * order = g_malloc (
sizeof (
char *) * (lists + 1));
364 GHashTable * saved = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
NULL);
366 for (
int i = 0; i < lists; i ++)
369 order[i] = g_strdup_printf (
"%d",
id);
373 char * path = g_strdup_printf (
"%s/%d.audpl", folder,
id);
383 g_hash_table_insert (saved, g_strdup_printf (
"%d.audpl",
id),
NULL);
387 char * order_string = g_strjoinv (
" ", order);
393 char * old_order_string;
394 g_file_get_contents (order_path, & old_order_string,
NULL,
NULL);
396 if (! old_order_string || strcmp (old_order_string, order_string))
398 if (! g_file_set_contents (order_path, order_string, -1, & error))
400 fprintf (stderr,
"Cannot write to %s: %s\n", order_path, error->message);
401 g_error_free (error);
405 g_free (order_string);
407 g_free (old_order_string);
415 DIR * dir = opendir (folder);
419 struct dirent *
entry;
420 while ((entry = readdir (dir)))
422 if (! g_str_has_suffix (entry->d_name,
".audpl")
423 && ! g_str_has_suffix (entry->d_name,
".xspf"))
426 if (! g_hash_table_lookup_extended (saved, entry->d_name,
NULL,
NULL))
428 char * path = g_strdup_printf (
"%s/%s", folder, entry->d_name);
437 g_hash_table_destroy (saved);