diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2020-04-26 23:59:57 -0700 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2020-04-27 21:10:58 -0700 |
commit | 430b6f9f1215f1fa33500003d200a83de29e56d3 (patch) | |
tree | d40e773f6789b03d650a7ed232f7568a30acdaa3 /stream/stream_libarchive.c | |
parent | 027ae815ec3a726a5138c04fb6e4296c5f6aee39 (diff) | |
download | mpv-430b6f9f1215f1fa33500003d200a83de29e56d3.tar.bz2 mpv-430b6f9f1215f1fa33500003d200a83de29e56d3.tar.xz |
stream_libarchive: put multi_rar check in a function
Diffstat (limited to 'stream/stream_libarchive.c')
-rw-r--r-- | stream/stream_libarchive.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/stream/stream_libarchive.c b/stream/stream_libarchive.c index d5d8dca3ff..0b48233f8c 100644 --- a/stream/stream_libarchive.c +++ b/stream/stream_libarchive.c @@ -42,6 +42,19 @@ static bool probe_rar(struct stream *s) return memcmp(buf, rar_sig, 6) == 0; } +static bool probe_multi_rar(struct stream *s) +{ + uint8_t hdr[14]; + if (stream_read_peek(s, hdr, sizeof(hdr)) == sizeof(hdr)) { + // Look for rar mark head & main head (assume they're in order). + if (hdr[6] == 0x00 && hdr[7 + 2] == 0x73) { + int rflags = hdr[7 + 3] | (hdr[7 + 4] << 8); + return rflags & 0x100; + } + } + return false; +} + static bool probe_zip(struct stream *s) { uint8_t p[4]; @@ -300,16 +313,7 @@ struct mp_archive *mp_archive_new(struct mp_log *log, struct stream *src, bool maybe_rar = probe_rar(src); bool maybe_zip = probe_zip(src); bool probe_all = flags & MP_ARCHIVE_FLAG_UNSAFE; - bool maybe_rar2_multivol = false; - - uint8_t hdr[14]; - if (maybe_rar && stream_read_peek(src, hdr, sizeof(hdr)) == sizeof(hdr)) { - // Look for rar mark head & main head (assume they're in order). - if (hdr[6] == 0x00 && hdr[7 + 2] == 0x73) { - int rflags = hdr[7 + 3] | (hdr[7 + 4] << 8); - maybe_rar2_multivol = rflags & 0x100; - } - } + bool maybe_rar2_multivol = maybe_rar && probe_multi_rar(src); bool is_multivolume = false; if (!(flags & MP_ARCHIVE_FLAG_NO_RAR_VOLUMES)) { |