diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-17 21:02:51 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-17 21:02:51 +0100 |
commit | bb56941f6b61529dd770475296d093727c68fdc6 (patch) | |
tree | 065c61ef71a00d0759afcdc0316150db278a7efd /config.cpp | |
parent | 22ed919b2fffa933c8a72763fda2b603a92a18cf (diff) |
Automatically use correct files path (executable path or /media/usb)
Diffstat (limited to 'config.cpp')
-rw-r--r-- | config.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/config.cpp b/config.cpp new file mode 100644 index 0000000..beb7f97 --- /dev/null +++ b/config.cpp @@ -0,0 +1,26 @@ +#include "config.h" + +#include <string> +#include <filesystem> + +namespace fs = std::filesystem; + +Config::Config(int argc, char* argv[]) +{ + m_executable_path = fs::path{argv[0]}.parent_path().string(); +} + +std::string Config::get_executable_path() +{ + return m_executable_path; +} + +std::string Config::get_file_path() +{ + // Just a heuristic: If this exists in current dir, then use this path + if (fs::exists(fs::path{m_executable_path} / "magic1.midi")) { + return m_executable_path; + } + return "/media/usb"; +} + |