directory_for_each_song_safe(song, ns, directory) { assert(song->parent == directory); char *name_fs = utf8_to_fs_charset(song->uri); if (exclude_list_check(exclude_list, name_fs)) { delete_song(directory, song); modified = true; } g_free(name_fs); }
/* passed to songvec_for_each */ static int delete_song_if_excluded(struct song *song, void *_data) { GSList *exclude_list = _data; char *name_fs; assert(song->parent != NULL); name_fs = utf8_to_fs_charset(song->uri); if (exclude_list_check(exclude_list, name_fs)) { delete_song(song->parent, song); modified = true; } g_free(name_fs); return 0; }
static void remove_excluded_from_directory(struct directory *directory, GSList *exclude_list) { db_lock(); struct directory *child, *n; directory_for_each_child_safe(child, n, directory) { char *name_fs = utf8_to_fs_charset(directory_get_name(child)); if (exclude_list_check(exclude_list, name_fs)) { delete_directory(child); modified = true; } g_free(name_fs); }
static void remove_excluded_from_directory(struct directory *directory, GSList *exclude_list) { int i; struct dirvec *dv = &directory->children; for (i = dv->nr; --i >= 0; ) { struct directory *child = dv->base[i]; char *name_fs = utf8_to_fs_charset(directory_get_name(child)); if (exclude_list_check(exclude_list, name_fs)) { delete_directory(child); modified = true; } g_free(name_fs); } songvec_for_each(&directory->songs, delete_song_if_excluded, exclude_list); }
static bool updateDirectory(struct directory *directory, const struct stat *st) { DIR *dir; struct dirent *ent; char *path_fs, *exclude_path_fs; GSList *exclude_list; assert(S_ISDIR(st->st_mode)); directory_set_stat(directory, st); path_fs = map_directory_fs(directory); if (path_fs == NULL) return false; dir = opendir(path_fs); if (!dir) { g_warning("Failed to open directory %s: %s", path_fs, g_strerror(errno)); g_free(path_fs); return false; } exclude_path_fs = g_build_filename(path_fs, ".mpdignore", NULL); exclude_list = exclude_list_load(exclude_path_fs); g_free(exclude_path_fs); g_free(path_fs); if (exclude_list != NULL) remove_excluded_from_directory(directory, exclude_list); removeDeletedFromDirectory(directory); while ((ent = readdir(dir))) { char *utf8; struct stat st2; if (skip_path(ent->d_name) || exclude_list_check(exclude_list, ent->d_name)) continue; utf8 = fs_charset_to_utf8(ent->d_name); if (utf8 == NULL) continue; if (skip_symlink(directory, utf8)) { delete_name_in(directory, utf8); g_free(utf8); continue; } if (stat_directory_child(directory, utf8, &st2) == 0) updateInDirectory(directory, utf8, &st2); else delete_name_in(directory, utf8); g_free(utf8); } exclude_list_free(exclude_list); closedir(dir); directory->mtime = st->st_mtime; return true; }