aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/LocalOpen.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-02 21:17:31 +0200
committerMax Kellermann <max@duempel.org>2014-10-02 21:50:14 +0200
commit7e12aea1d8f90d375627acc9f4a532009781aa26 (patch)
tree9092dc1a8e12928af37e234f4b1d57f42891c8d3 /src/input/LocalOpen.cxx
parent20346b0da454a114a9eb3dc99fcdf5f984d45240 (diff)
downloadmpd-7e12aea1d8f90d375627acc9f4a532009781aa26.tar.gz
mpd-7e12aea1d8f90d375627acc9f4a532009781aa26.tar.xz
mpd-7e12aea1d8f90d375627acc9f4a532009781aa26.zip
input/Open: use OpenLocalInputStream()
Make the "open" method of plugins "file" and "archive" dummy methods that always fail. Instead, let InputStream::Open() hard-code access to these two plugins by using OpenLocalInputStream(). This allows simplifyin the algorithm for falling back to probing archive plugins.
Diffstat (limited to 'src/input/LocalOpen.cxx')
-rw-r--r--src/input/LocalOpen.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/input/LocalOpen.cxx b/src/input/LocalOpen.cxx
index a1ac2b856..ad8eba8ce 100644
--- a/src/input/LocalOpen.cxx
+++ b/src/input/LocalOpen.cxx
@@ -31,6 +31,10 @@
#include <assert.h>
+#ifdef ENABLE_ARCHIVE
+#include <errno.h>
+#endif
+
InputStream *
OpenLocalInputStream(Path path, Mutex &mutex, Cond &cond, Error &error)
{
@@ -38,8 +42,15 @@ OpenLocalInputStream(Path path, Mutex &mutex, Cond &cond, Error &error)
InputStream *is = OpenFileInputStream(path, mutex, cond, error);
#ifdef ENABLE_ARCHIVE
- if (is == nullptr && !error.IsDefined())
- is = OpenArchiveInputStream(path, mutex, cond, error);
+ if (is == nullptr && error.IsDomain(errno_domain) &&
+ error.GetCode() == ENOTDIR) {
+ /* ENOTDIR means this may be a path inside an archive
+ file */
+ Error error2;
+ is = OpenArchiveInputStream(path, mutex, cond, error2);
+ if (is == nullptr && error2.IsDefined())
+ error = std::move(error2);
+ }
#endif
assert(is == nullptr || is->IsReady());