diff options
Diffstat (limited to 'src/InputStream.cxx')
-rw-r--r-- | src/InputStream.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/InputStream.cxx b/src/InputStream.cxx index 28a0aad1a..7d3ebe615 100644 --- a/src/InputStream.cxx +++ b/src/InputStream.cxx @@ -57,6 +57,28 @@ InputStream::Open(const char *url, return nullptr; } +InputStream * +InputStream::OpenReady(const char *uri, + Mutex &mutex, Cond &cond, + Error &error) +{ + InputStream *is = Open(uri, mutex, cond, error); + if (is == nullptr) + return nullptr; + + mutex.lock(); + is->WaitReady(); + bool success = is->Check(error); + mutex.unlock(); + + if (!success) { + is->Close(); + is = nullptr; + } + + return is; +} + bool InputStream::Check(Error &error) { |