From cb713f7c476ee67a2a15ffaa13375ecf8b06a445 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 16 Mar 2019 21:05:24 +0100 Subject: Use search path facilities to find modules --- src/World.cpp | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index b967de2f..693f9427 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -66,40 +66,21 @@ class Store; static std::unique_ptr ingen_load_library(Log& log, const string& name) { - std::unique_ptr library; - - // Search INGEN_MODULE_PATH first - const char* const module_path = getenv("INGEN_MODULE_PATH"); - if (module_path) { - string dir; - std::istringstream iss(module_path); - while (getline(iss, dir, search_path_separator)) { - FilePath filename = ingen::ingen_module_path(name, FilePath(dir)); - if (filesystem::exists(filename)) { - library = std::unique_ptr(new Library(filename)); - if (*library) { - return library; - } else { - log.error(Library::get_last_error()); - } - } - } + const auto path = ingen_module_path(name); + if (path.empty()) { + log.error("Failed to find %1% (%2%)\n", + name, Library::get_last_error()); + return nullptr; } - // Try default directory if not found - library = std::unique_ptr(new Library(ingen::ingen_module_path(name))); - + UPtr library = make_unique(path); if (*library) { return library; - } else if (!module_path) { - log.error("Unable to find %1% (%2%)\n", - name, Library::get_last_error()); - return nullptr; - } else { - log.error("Unable to load %1% from %2% (%3%)\n", - name, module_path, Library::get_last_error()); - return nullptr; } + + log.error("Unable to load %1% from %2% (%3%)\n", + name, path, Library::get_last_error()); + return nullptr; } class World::Impl { -- cgit v1.2.1