diff options
author | Max Kellermann <max@musicpd.org> | 2017-12-26 20:05:22 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-12-26 20:05:22 +0100 |
commit | 7bce6329e3a70130b1f2fb5aecc7d125c46291b0 (patch) | |
tree | 0f4c761de7244f0f2905cd83c47fb0ab11e2cbe5 /src/archive | |
parent | 49619fbd775f8958e29dae083c3a345f5572d249 (diff) |
archive/File, input/Plugin: return InputStreamPtr
Diffstat (limited to 'src/archive')
-rw-r--r-- | src/archive/ArchiveFile.hxx | 7 | ||||
-rw-r--r-- | src/archive/plugins/Bzip2ArchivePlugin.cxx | 8 | ||||
-rw-r--r-- | src/archive/plugins/Iso9660ArchivePlugin.cxx | 10 | ||||
-rw-r--r-- | src/archive/plugins/ZzipArchivePlugin.cxx | 12 |
4 files changed, 19 insertions, 18 deletions
diff --git a/src/archive/ArchiveFile.hxx b/src/archive/ArchiveFile.hxx index 72f72d7b9..00c528e40 100644 --- a/src/archive/ArchiveFile.hxx +++ b/src/archive/ArchiveFile.hxx @@ -20,10 +20,11 @@ #ifndef MPD_ARCHIVE_FILE_HXX #define MPD_ARCHIVE_FILE_HXX +#include "input/Ptr.hxx" + class Mutex; class Cond; class ArchiveVisitor; -class InputStream; class ArchiveFile { public: @@ -41,8 +42,8 @@ public: * * @param path the path within the archive */ - virtual InputStream *OpenStream(const char *path, - Mutex &mutex, Cond &cond) = 0; + virtual InputStreamPtr OpenStream(const char *path, + Mutex &mutex, Cond &cond) = 0; }; #endif diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx index b8bad8826..0cd849c19 100644 --- a/src/archive/plugins/Bzip2ArchivePlugin.cxx +++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx @@ -53,8 +53,8 @@ public: visitor.VisitArchiveEntry(name.c_str()); } - InputStream *OpenStream(const char *path, - Mutex &mutex, Cond &cond) override; + InputStreamPtr OpenStream(const char *path, + Mutex &mutex, Cond &cond) override; }; class Bzip2InputStream final : public InputStream { @@ -127,11 +127,11 @@ Bzip2InputStream::~Bzip2InputStream() BZ2_bzDecompressEnd(&bzstream); } -InputStream * +InputStreamPtr Bzip2ArchiveFile::OpenStream(const char *path, Mutex &mutex, Cond &cond) { - return new Bzip2InputStream(istream, path, mutex, cond); + return std::make_unique<Bzip2InputStream>(istream, path, mutex, cond); } inline bool diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx index 62f61d596..5a20c637c 100644 --- a/src/archive/plugins/Iso9660ArchivePlugin.cxx +++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx @@ -74,8 +74,8 @@ public: virtual void Visit(ArchiveVisitor &visitor) override; - InputStream *OpenStream(const char *path, - Mutex &mutex, Cond &cond) override; + InputStreamPtr OpenStream(const char *path, + Mutex &mutex, Cond &cond) override; }; /* archive open && listing routine */ @@ -156,7 +156,7 @@ public: size_t Read(void *ptr, size_t size) override; }; -InputStream * +InputStreamPtr Iso9660ArchiveFile::OpenStream(const char *pathname, Mutex &mutex, Cond &cond) { @@ -165,8 +165,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname, throw FormatRuntimeError("not found in the ISO file: %s", pathname); - return new Iso9660InputStream(iso, pathname, mutex, cond, - statbuf); + return std::make_unique<Iso9660InputStream>(iso, pathname, mutex, cond, + statbuf); } size_t diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx index fc40e7689..5660e4286 100644 --- a/src/archive/plugins/ZzipArchivePlugin.cxx +++ b/src/archive/plugins/ZzipArchivePlugin.cxx @@ -59,8 +59,8 @@ public: virtual void Visit(ArchiveVisitor &visitor) override; - InputStream *OpenStream(const char *path, - Mutex &mutex, Cond &cond) override; + InputStreamPtr OpenStream(const char *path, + Mutex &mutex, Cond &cond) override; }; /* archive open && listing routine */ @@ -116,7 +116,7 @@ public: void Seek(offset_type offset) override; }; -InputStream * +InputStreamPtr ZzipArchiveFile::OpenStream(const char *pathname, Mutex &mutex, Cond &cond) { @@ -125,9 +125,9 @@ ZzipArchiveFile::OpenStream(const char *pathname, throw FormatRuntimeError("not found in the ZIP file: %s", pathname); - return new ZzipInputStream(dir, pathname, - mutex, cond, - _file); + return std::make_unique<ZzipInputStream>(dir, pathname, + mutex, cond, + _file); } size_t |