summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.c14
-rw-r--r--stream/stream.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/stream/stream.c b/stream/stream.c
index d6521586b5..35d09ad023 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -929,6 +929,20 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
return (struct bstr){buf, total_read};
}
+struct bstr stream_read_file(const char *filename, void *talloc_ctx,
+ struct mpv_global *global, int max_size)
+{
+ struct bstr res = {0};
+ char *fname = mp_get_user_path(NULL, global, filename);
+ stream_t *s = stream_open(fname, global);
+ if (s) {
+ res = stream_read_complete(s, talloc_ctx, max_size);
+ free_stream(s);
+ }
+ talloc_free(fname);
+ return res;
+}
+
struct mp_cancel {
atomic_bool triggered;
#ifdef __MINGW32__
diff --git a/stream/stream.h b/stream/stream.h
index cda5c7434e..981c90cf5e 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -258,6 +258,8 @@ struct mpv_global;
struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
int max_size);
+struct bstr stream_read_file(const char *filename, void *talloc_ctx,
+ struct mpv_global *global, int max_size);
int stream_control(stream_t *s, int cmd, void *arg);
void free_stream(stream_t *s);
struct stream *stream_create(const char *url, int flags,