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);
static char * make_playlist_path(int playlist)
void playlist_insert_with_id(int at, int id)
void playlist_select_by_patterns(int playlist, const Tuple *patterns)
int playlist_get_unique_id(int playlist_num)
void playlist_sort_by_scheme(int playlist, int scheme)
void playlist_sort_selected_by_filename(int playlist_num, int(*compare)(const char *a, const char *b))
int(* PlaylistTupleCompareFunc)(const Tuple *a, const Tuple *b)
static float a[EQ_BANDS][2]
void load_playlists(void)
static void load_playlists_real(void)
static void state_cb(void *data, void *user)
void playlist_sort_selected_by_title(int playlist_num, int(*compare)(const char *a, const char *b))
const char PluginHandle decoder const char PluginHandle decoder const char PluginHandle decoder void const PreferencesWidget int
bool_t playlist_entry_get_selected(int playlist_num, int entry_num)
static float b[EQ_BANDS][2]
int playlist_entry_count(int playlist_num)
void playlist_entry_set_selected(int playlist_num, int entry_num, bool_t selected)
int(* PlaylistStringCompareFunc)(const char *a, const char *b)
void playlist_remove_failed(int playlist)
File name part of the location URI.
EXPORT void hook_associate(const char *name, HookFunction func, void *user)
EXPORT int string_compare(const char *ap, const char *bp)
static int tuple_compare_artist(const Tuple *a, const Tuple *b)
void playlist_sort_by_title(int playlist_num, int(*compare)(const char *a, const char *b))
#define hook_dissociate(n, f)
static const PlaylistStringCompareFunc filename_comparisons[]
bool_t playlist_insert_playlist_raw(int list, int at, const char *filename)
static bool_t hooks_added
void playlist_load_state(void)
Tuple * playlist_entry_get_tuple(int playlist_num, int entry_num, bool_t fast)
static int tuple_compare_length(const Tuple *a, const Tuple *b)
void playlist_select_all(int playlist_num, bool_t selected)
void playlist_set_active(int playlist_num)
EXPORT void tuple_unref(Tuple *tuple)
EXPORT int string_compare_encoded(const char *ap, const char *bp)
static int tuple_compare_album(const Tuple *a, const Tuple *b)
void save_playlists(bool_t exiting)
static const PlaylistTupleCompareFunc tuple_comparisons[]
void playlist_save_state(void)
char * playlist_entry_get_filename(int playlist_num, int entry_num)
bool_t playlist_get_modified(int playlist_num)
void playlist_sort_selected_by_scheme(int playlist, int scheme)
void str_unref(char *str)
static int tuple_compare_track(const Tuple *a, const Tuple *b)
void playlist_sort_by_tuple(int playlist_num, int(*compare)(const Tuple *a, const Tuple *b))
const char * get_path(int id)
static bool_t state_changed
EXPORT char * tuple_get_str(const Tuple *tuple, int nfield, const char *field)
void playlist_set_modified(int playlist_num, bool_t modified)
static int filename_compare_basename(const char *a, const char *b)
static const char * get_basename(const char *filename)
EXPORT TupleValueType tuple_get_value_type(const Tuple *tuple, int nfield, const char *field)
Returns TupleValueType of given #Tuple field.
static const PlaylistStringCompareFunc title_comparisons[]
static int tuple_compare_string(const Tuple *a, const Tuple *b, int field)
static void save_playlists_real(void)
static void update_cb(void *data, void *user)
Track length in milliseconds.
EXPORT char * filename_to_uri(const char *name)
void playlist_remove_duplicates_by_scheme(int playlist, int scheme)
static int tuple_compare_int(const Tuple *a, const Tuple *b, int field)
void playlist_delete_selected(int playlist_num)
void playlist_insert(int at)
static int tuple_compare_date(const Tuple *a, const Tuple *b)
void playlist_sort_selected_by_tuple(int playlist_num, int(*compare)(const Tuple *a, const Tuple *b))
bool_t playlist_save(int list, const char *filename)
void playlist_sort_by_filename(int playlist_num, int(*compare)(const char *a, const char *b))
Year of production/performance/etc.
EXPORT bool_t vfs_file_test(const char *path, int test)
Wrapper for g_file_test().
static int tuple_compare_title(const Tuple *a, const Tuple *b)
EXPORT int tuple_get_int(const Tuple *tuple, int nfield, const char *field)
Returns integer associated to #Tuple field.