summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/config.cpp b/config.cpp
index d0a7671..d51f6f6 100644
--- a/config.cpp
+++ b/config.cpp
@@ -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