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/runtime_paths.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/runtime_paths.cpp')
-rw-r--r-- | src/runtime_paths.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp index 471e2ba2..c4ee7c2b 100644 --- a/src/runtime_paths.cpp +++ b/src/runtime_paths.cpp @@ -108,34 +108,30 @@ bundle_file_path(const std::string& name) return bundle_path / name; } -/** Return the absolute path of a 'resource' file. - */ FilePath data_file_path(const std::string& name) { -#ifdef BUNDLE - return bundle_path / INGEN_DATA_DIR / name; -#else return find_in_search_path(name, data_dirs()); -#endif } -/** Return the absolute path of a module (dynamically loaded shared library). - */ -FilePath -ingen_module_path(const std::string& name, FilePath dir) +std::vector<FilePath> +ingen_module_dirs() { - FilePath ret; - if (dir.empty()) { #ifdef BUNDLE - dir = FilePath(bundle_path) / INGEN_MODULE_DIR; + const FilePath default_dir = FilePath(bundle_path) / INGEN_MODULE_DIR; #else - dir = FilePath(INGEN_MODULE_DIR); + const FilePath default_dir = INGEN_MODULE_DIR; #endif - } - return dir / - (std::string(library_prefix) + "ingen_" + name + library_suffix); + return parse_search_path(getenv("INGEN_MODULE_PATH"), {default_dir}); +} + +FilePath +ingen_module_path(const std::string& name) +{ + return find_in_search_path( + std::string(library_prefix) + "ingen_" + name + library_suffix, + ingen_module_dirs()); } FilePath @@ -189,9 +185,15 @@ data_dirs() { std::vector<FilePath> paths = system_data_dirs(); const FilePath user_dir = user_data_dir(); + +#ifdef BUNDLE + paths.insert(paths.begin(), bundle_path / INGEN_DATA_DIR); +#endif + if (!user_dir.empty()) { paths.insert(paths.begin(), user_dir); } + return paths; } |