From bb56941f6b61529dd770475296d093727c68fdc6 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 17 Jan 2025 21:02:51 +0100 Subject: Automatically use correct files path (executable path or /media/usb) --- config.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 config.cpp (limited to 'config.cpp') 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 +#include + +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"; +} + -- cgit v1.2.3