diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-20 11:07:47 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-20 11:07:47 +0100 |
commit | 78ace79b86aeba3575b2abe2ba617798f6d8da85 (patch) | |
tree | 53343326b96229d4930f2c6650b52d930f03f4b6 | |
parent | b527be73791648a6fa424a3b654d84374bb0bd86 (diff) |
Install click file
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | config.cpp | 16 |
2 files changed, 17 insertions, 1 deletions
@@ -47,6 +47,8 @@ $(TARGET): $(OBJS) install: mkdir -p $(DESTDIR)/usr/bin cp $(TARGET) $(DESTDIR)/usr/bin + mkdir -p $(DESTDIR)/usr/lib/click/media + cp media/click.s16le $(DESTDIR)/usr/lib/click/media clean: rm -f $(TARGET) $(OBJS) @@ -19,6 +19,8 @@ std::string config_filename = "click.cfg"; fs::path click_data_filename = "media/click.s16le"; +fs::path libdir = "/usr/lib/click"; + const std::string programname = "click"; Config::Config(int argc, char** argv): @@ -161,7 +163,19 @@ std::string Config::get_argv(int i) const std::filesystem::path Config::get_click_data_filename() const { - return fs::path{m_argv[0]}.parent_path() / click_data_filename; + // 1st try: executable-local media/click.s16le + fs::path result{fs::path{m_argv[0]}.parent_path() / click_data_filename}; + if (fs::exists(result)) { + return result; + } + + // 2nd try: + result = libdir / click_data_filename; + if (fs::exists(result)) { + return result; + } + + throw std::runtime_error("Click file not found"); } std::string Config::get_programname() const |