summaryrefslogtreecommitdiffstats
path: root/src/runtime_paths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime_paths.cpp')
-rw-r--r--src/runtime_paths.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index 38eb681f..17167e9a 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -14,15 +14,15 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/runtime_paths.hpp"
+#include <ingen/runtime_paths.hpp>
+
+#include <ingen/FilePath.hpp>
-#include "ingen/FilePath.hpp"
-#include "ingen/filesystem.hpp"
#include "ingen_config.h"
-#include <algorithm>
#include <cstdlib>
#include <dlfcn.h>
+#include <filesystem>
#include <sstream>
#include <string>
@@ -45,7 +45,8 @@ static const char* const library_suffix = ".so";
#endif
static std::vector<FilePath>
-parse_search_path(const char* search_path, std::vector<FilePath> defaults)
+parse_search_path(const char* search_path,
+ const std::vector<FilePath>& defaults)
{
if (!search_path) {
return defaults;
@@ -70,7 +71,7 @@ set_bundle_path_from_code(void (*function)())
Dl_info dli;
dladdr(reinterpret_cast<void*>(function), &dli);
-#ifdef BUNDLE
+#if INGEN_BUNDLED
char bin_loc[PATH_MAX];
realpath(dli.dli_fname, bin_loc);
#else
@@ -92,7 +93,7 @@ find_in_search_path(const std::string& name,
{
for (const auto& dir : search_path) {
FilePath path = dir / name;
- if (filesystem::exists(path)) {
+ if (std::filesystem::exists(path)) {
return path;
}
}
@@ -117,7 +118,7 @@ data_file_path(const std::string& name)
std::vector<FilePath>
ingen_module_dirs()
{
-#ifdef BUNDLE
+#if INGEN_BUNDLED
const FilePath default_dir = FilePath(bundle_path) / INGEN_MODULE_DIR;
#else
const FilePath default_dir = INGEN_MODULE_DIR;
@@ -138,22 +139,28 @@ FilePath
user_config_dir()
{
if (const char* xdg_config_home = getenv("XDG_CONFIG_HOME")) {
- return FilePath(xdg_config_home);
- } else if (const char* home = getenv("HOME")) {
+ return {xdg_config_home};
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".config";
}
- return FilePath();
+
+ return {};
}
FilePath
user_data_dir()
{
if (const char* xdg_data_home = getenv("XDG_DATA_HOME")) {
- return FilePath(xdg_data_home);
- } else if (const char* home = getenv("HOME")) {
+ return {xdg_data_home};
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".local/share";
}
- return FilePath();
+
+ return {};
}
std::vector<FilePath>
@@ -186,7 +193,7 @@ data_dirs()
std::vector<FilePath> paths = system_data_dirs();
const FilePath user_dir = user_data_dir();
-#ifdef BUNDLE
+#if INGEN_BUNDLED
paths.insert(paths.begin(), bundle_path / INGEN_DATA_DIR);
#endif