aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/playlist_list.c36
-rw-r--r--src/playlist_list.h11
2 files changed, 47 insertions, 0 deletions
diff --git a/src/playlist_list.c b/src/playlist_list.c
index 9b2395ad4..b5df72ed8 100644
--- a/src/playlist_list.c
+++ b/src/playlist_list.c
@@ -204,3 +204,39 @@ playlist_list_open_stream(struct input_stream *is, const char *uri)
return NULL;
}
+
+static bool
+playlist_suffix_supported(const char *suffix)
+{
+ assert(suffix != NULL);
+
+ for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
+ const struct playlist_plugin *plugin = playlist_plugins[i];
+
+ if (playlist_plugins_enabled[i] &&
+ stringFoundInStringArray(plugin->suffixes, suffix))
+ return true;
+ }
+
+ return false;
+}
+
+struct playlist_provider *
+playlist_list_open_path(struct input_stream *is, const char *path_fs)
+{
+ const char *suffix;
+ struct playlist_provider *playlist;
+
+ assert(path_fs != NULL);
+
+ suffix = uri_get_suffix(path_fs);
+ if (suffix == NULL || !playlist_suffix_supported(suffix) ||
+ !input_stream_open(is, path_fs))
+ return NULL;
+
+ playlist = playlist_list_open_stream_suffix(is, suffix);
+ if (playlist == NULL)
+ input_stream_close(is);
+
+ return playlist;
+}
diff --git a/src/playlist_list.h b/src/playlist_list.h
index b5ac52a6f..ebfc5c509 100644
--- a/src/playlist_list.h
+++ b/src/playlist_list.h
@@ -51,4 +51,15 @@ playlist_list_open_uri(const char *uri);
struct playlist_provider *
playlist_list_open_stream(struct input_stream *is, const char *uri);
+/**
+ * Opens a playlist from a local file.
+ *
+ * @param is an uninitialized #input_stream object (must be closed
+ * with input_stream_close() if this function succeeds)
+ * @param path_fs the path of the playlist file
+ * @return a playlist, or NULL on error
+ */
+struct playlist_provider *
+playlist_list_open_path(struct input_stream *is, const char *path_fs);
+
#endif