diff options
author | David Robillard <d@drobilla.net> | 2019-03-16 21:05:24 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-03-16 21:05:24 +0100 |
commit | cb713f7c476ee67a2a15ffaa13375ecf8b06a445 (patch) | |
tree | 29e2d651a73d5d9239284d84a8d091cdd0d91417 /src/World.cpp | |
parent | f7ace4ffc6dabd93a4d0abc6121dd8dd87ce7af1 (diff) | |
download | ingen-cb713f7c476ee67a2a15ffaa13375ecf8b06a445.tar.gz ingen-cb713f7c476ee67a2a15ffaa13375ecf8b06a445.tar.bz2 ingen-cb713f7c476ee67a2a15ffaa13375ecf8b06a445.zip |
Use search path facilities to find modules
Diffstat (limited to 'src/World.cpp')
-rw-r--r-- | src/World.cpp | 39 |
1 files changed, 10 insertions, 29 deletions
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<Library> ingen_load_library(Log& log, const string& name) { - std::unique_ptr<Library> 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<Library>(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<Library>(new Library(ingen::ingen_module_path(name))); - + UPtr<Library> library = make_unique<Library>(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 { |