storage/Plugin: return std::unique_ptr<Storage>

This commit is contained in:
Max Kellermann
2018-01-02 16:11:17 +01:00
parent 3f4f7b0a53
commit 3c5e4e2788
15 changed files with 46 additions and 32 deletions

View File

@@ -34,10 +34,10 @@
#include <string.h>
#include <time.h>
static Storage *
static std::unique_ptr<Storage>
MakeStorage(EventLoop &event_loop, const char *uri)
{
Storage *storage = CreateStorageURI(event_loop, uri);
auto storage = CreateStorageURI(event_loop, uri);
if (storage == nullptr)
throw std::runtime_error("Unrecognized storage URI");
@@ -108,8 +108,8 @@ try {
const char *const path = argv[3];
std::unique_ptr<Storage> storage(MakeStorage(io_thread.GetEventLoop(),
storage_uri));
auto storage = MakeStorage(io_thread.GetEventLoop(),
storage_uri);
return Ls(*storage, path);
} else {

View File

@@ -14,6 +14,7 @@
#include "ls.hxx"
#include "Log.hxx"
#include "db/DatabaseSong.hxx"
#include "storage/StorageInterface.hxx"
#include "storage/plugins/LocalStorage.hxx"
#include "Mapper.hxx"
#include "util/ChronoUtil.hxx"
@@ -309,7 +310,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION(TranslateSongTest);
int
main(gcc_unused int argc, gcc_unused char **argv)
{
storage = CreateLocalStorage(Path::FromFS(music_directory));
auto _storage = CreateLocalStorage(Path::FromFS(music_directory));
storage = _storage.get();
CppUnit::TextUi::TestRunner runner;
auto &registry = CppUnit::TestFactoryRegistry::getRegistry();