input/Plugin: migrate open() from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-09-09 15:37:06 +02:00
parent 63ab7767a3
commit fc7d3f64c0
44 changed files with 359 additions and 461 deletions

View File

@@ -29,6 +29,7 @@
#include "input/InputStream.hxx"
#include "fs/Path.hxx"
#include "util/RefCount.hxx"
#include "util/RuntimeError.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
@@ -58,9 +59,8 @@ public:
virtual void Visit(ArchiveVisitor &visitor) override;
virtual InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond,
Error &error) override;
InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond) override;
};
static constexpr Domain zzip_domain("zzip");
@@ -129,15 +129,12 @@ struct ZzipInputStream final : public InputStream {
InputStream *
ZzipArchiveFile::OpenStream(const char *pathname,
Mutex &mutex, Cond &cond,
Error &error)
Mutex &mutex, Cond &cond)
{
ZZIP_FILE *_file = zzip_file_open(dir, pathname, 0);
if (_file == nullptr) {
error.Format(zzip_domain, "not found in the ZIP file: %s",
pathname);
return nullptr;
}
if (_file == nullptr)
throw FormatRuntimeError("not found in the ZIP file: %s",
pathname);
return new ZzipInputStream(*this, pathname,
mutex, cond,