struct playlist_provider * playlist_list_open_path(const char *path_fs) { GError *error = NULL; const char *suffix; struct input_stream *is; struct playlist_provider *playlist; assert(path_fs != NULL); suffix = uri_get_suffix(path_fs); if (suffix == NULL || !playlist_suffix_supported(suffix)) return NULL; is = input_stream_open(path_fs, &error); if (is == NULL) { if (error != NULL) { g_warning("%s", error->message); g_error_free(error); } return NULL; } while (!is->ready) { int ret = input_stream_buffer(is, &error); if (ret < 0) { input_stream_close(is); g_warning("%s", error->message); g_error_free(error); return NULL; } } playlist = playlist_list_open_stream_suffix(is, suffix); if (playlist == NULL) input_stream_close(is); return playlist; }
static void update_regular_file(struct directory *directory, const char *name, const struct stat *st) { const char *suffix = uri_get_suffix(name); const struct decoder_plugin* plugin; #ifdef ENABLE_ARCHIVE const struct archive_plugin *archive; #endif if (suffix == NULL) return; if ((plugin = decoder_plugin_from_suffix(suffix, false)) != NULL) { struct song* song = songvec_find(&directory->songs, name); if (!directory_child_access(directory, name, R_OK)) { g_warning("no read permissions on %s/%s", directory_get_path(directory), name); if (song != NULL) delete_song(directory, song); return; } if (!(song != NULL && st->st_mtime == song->mtime && !walk_discard) && plugin->container_scan != NULL) { if (update_container_file(directory, name, st, plugin)) { if (song != NULL) delete_song(directory, song); return; } } if (song == NULL) { song = song_file_load(name, directory); if (song == NULL) { g_debug("ignoring unrecognized file %s/%s", directory_get_path(directory), name); return; } songvec_add(&directory->songs, song); modified = true; g_message("added %s/%s", directory_get_path(directory), name); } else if (st->st_mtime != song->mtime || walk_discard) { g_message("updating %s/%s", directory_get_path(directory), name); if (!song_file_update(song)) { g_debug("deleting unrecognized file %s/%s", directory_get_path(directory), name); delete_song(directory, song); } modified = true; } #ifdef ENABLE_ARCHIVE } else if ((archive = archive_plugin_from_suffix(suffix))) { update_archive_file(directory, name, st, archive); #endif } else if (playlist_suffix_supported(suffix)) { if (playlist_vector_update_or_add(&directory->playlists, name, st->st_mtime)) modified = true; } }