diff options
-rw-r--r-- | src/Main.cxx | 5 | ||||
-rw-r--r-- | src/storage/plugins/LocalStorage.cxx | 13 | ||||
-rw-r--r-- | src/storage/plugins/LocalStorage.hxx | 2 | ||||
-rw-r--r-- | test/test_translate_song.cxx | 7 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index eb71372eb..82e0145cd 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -162,10 +162,7 @@ InitStorage(Error &error) path_fs.ChopSeparators(); CheckDirectoryReadable(path_fs); - const auto utf8 = path_fs.ToUTF8(); - assert(!utf8.empty()); - - instance->storage = CreateLocalStorage(utf8.c_str(), path_fs); + instance->storage = CreateLocalStorage(path_fs); return true; } diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx index 5020a8fd6..2bf430b2e 100644 --- a/src/storage/plugins/LocalStorage.cxx +++ b/src/storage/plugins/LocalStorage.cxx @@ -50,12 +50,15 @@ public: }; class LocalStorage final : public Storage { - const std::string base_utf8; const AllocatedPath base_fs; + const std::string base_utf8; public: - LocalStorage(const char *_base_utf8, Path _base_fs) - :base_utf8(_base_utf8), base_fs(_base_fs) {} + explicit LocalStorage(Path _base_fs) + :base_fs(_base_fs), base_utf8(base_fs.ToUTF8()) { + assert(!base_fs.IsNull()); + assert(!base_utf8.empty()); + } /* virtual methods from class Storage */ virtual bool GetInfo(const char *uri_utf8, bool follow, FileInfo &info, @@ -203,7 +206,7 @@ LocalDirectoryReader::GetInfo(bool follow, FileInfo &info, Error &error) } Storage * -CreateLocalStorage(const char *base_utf8, Path base_fs) +CreateLocalStorage(Path base_fs) { - return new LocalStorage(base_utf8, base_fs); + return new LocalStorage(base_fs); } diff --git a/src/storage/plugins/LocalStorage.hxx b/src/storage/plugins/LocalStorage.hxx index cad2d1e58..e80fd8276 100644 --- a/src/storage/plugins/LocalStorage.hxx +++ b/src/storage/plugins/LocalStorage.hxx @@ -28,6 +28,6 @@ class Path; gcc_malloc gcc_nonnull_all Storage * -CreateLocalStorage(const char *base_utf8, Path base_fs); +CreateLocalStorage(Path base_fs); #endif diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index 6ef3a13f5..bcd3e8646 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -38,9 +38,8 @@ uri_supported_scheme(const char *uri) return memcmp(uri, "http://", 7) == 0; } -const char *const music_directory = "/music"; -static Storage *const storage = CreateLocalStorage(music_directory, - Path::FromFS(music_directory)); +static const char *const music_directory = "/music"; +static Storage *storage; static void BuildTag(gcc_unused TagBuilder &tag) @@ -308,6 +307,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION(TranslateSongTest); int main(gcc_unused int argc, gcc_unused char **argv) { + storage = CreateLocalStorage(Path::FromFS(music_directory)); + CppUnit::TextUi::TestRunner runner; auto ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); |