1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-17 20:34:58 +00:00

input: use stream_read_file2 for reading config

The existing logic already duplicates stream_read_file other than
the flags. With stream_read_file2, this duplication can be removed.
This commit is contained in:
nanahi 2024-10-19 15:18:47 -04:00 committed by Kacper Michajłow
parent ac648d2e0b
commit 8c3fd2cd38

View File

@ -1469,16 +1469,11 @@ static bool parse_config_file(struct input_ctx *ictx, char *file)
{
bool r = false;
void *tmp = talloc_new(NULL);
stream_t *s = NULL;
file = mp_get_user_path(tmp, ictx->global, file);
s = stream_create(file, STREAM_ORIGIN_DIRECT | STREAM_READ, NULL, ictx->global);
if (!s || s->is_directory) {
MP_ERR(ictx, "Can't open input config file %s.\n", file);
goto done;
}
bstr data = stream_read_complete(s, tmp, 1000000);
bstr data = stream_read_file2(file, tmp, STREAM_ORIGIN_DIRECT | STREAM_READ,
ictx->global, 1000000);
if (data.start) {
MP_VERBOSE(ictx, "Parsing input config file %s\n", file);
bstr_eatstart0(&data, "\xEF\xBB\xBF"); // skip BOM
@ -1489,8 +1484,6 @@ static bool parse_config_file(struct input_ctx *ictx, char *file)
MP_ERR(ictx, "Error reading input config file %s\n", file);
}
done:
free_stream(s);
talloc_free(tmp);
return r;
}