| 16 | static constexpr Domain input_domain("input"); |
| 17 | |
| 18 | InputStreamPtr |
| 19 | OpenArchiveInputStream(Path path, Mutex &mutex) |
| 20 | { |
| 21 | const ArchivePlugin *arplug; |
| 22 | |
| 23 | ArchiveLookupResult l; |
| 24 | try { |
| 25 | l = LookupFile(path); |
| 26 | if (l.archive.IsNull()) { |
| 27 | return nullptr; |
| 28 | } |
| 29 | } catch (...) { |
| 30 | FmtDebug(input_domain, |
| 31 | "not an archive, lookup {:?} failed: {}", |
| 32 | path, std::current_exception()); |
| 33 | return nullptr; |
| 34 | } |
| 35 | |
| 36 | const char *suffix = l.archive.GetExtension(); |
| 37 | if (suffix == nullptr) |
| 38 | return nullptr; |
| 39 | |
| 40 | //check which archive plugin to use (by ext) |
| 41 | arplug = archive_plugin_from_suffix(suffix); |
| 42 | if (!arplug) { |
| 43 | return nullptr; |
| 44 | } |
| 45 | |
| 46 | return archive_file_open(arplug, l.archive) |
| 47 | ->OpenStream(l.inside.c_str(), mutex); |
| 48 | } |
no test coverage detected