stream: add stream_read_file2

This is stream_read_file with the ability to specify flags.
This commit is contained in:
nanahi
2024-10-19 15:14:22 -04:00
committed by Kacper Michajłow
parent 9737b99845
commit 7673c4e34a
2 changed files with 10 additions and 1 deletions

View File

@@ -848,9 +848,15 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
struct bstr stream_read_file(const char *filename, void *talloc_ctx, struct bstr stream_read_file(const char *filename, void *talloc_ctx,
struct mpv_global *global, int max_size) struct mpv_global *global, int max_size)
{ {
struct bstr res = {0};
int flags = STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | int flags = STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY |
STREAM_LESS_NOISE; STREAM_LESS_NOISE;
return stream_read_file2(filename, talloc_ctx, flags, global, max_size);
}
struct bstr stream_read_file2(const char *filename, void *talloc_ctx,
int flags, struct mpv_global *global, int max_size)
{
struct bstr res = {0};
stream_t *s = stream_create(filename, flags, NULL, global); stream_t *s = stream_create(filename, flags, NULL, global);
if (s) { if (s) {
if (s->is_directory) if (s->is_directory)

View File

@@ -228,6 +228,9 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
int max_size); int max_size);
struct bstr stream_read_file(const char *filename, void *talloc_ctx, struct bstr stream_read_file(const char *filename, void *talloc_ctx,
struct mpv_global *global, int max_size); struct mpv_global *global, int max_size);
// Like stream_read_file(), but allows specifying flags like with stream_create().
struct bstr stream_read_file2(const char *filename, void *talloc_ctx,
int flags, struct mpv_global *global, int max_size);
int stream_control(stream_t *s, int cmd, void *arg); int stream_control(stream_t *s, int cmd, void *arg);
void free_stream(stream_t *s); void free_stream(stream_t *s);