X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fresource.c;h=ec32a4420f7755de5c5491047a756c59d56d3ba7;hb=972398f471696e6c8995f7066d6f5a4a1d2b3552;hp=634159308ef5c057a51447e4327cc8d93c005065;hpb=7ade12b470366a03f7bf84e4989c9d3593dc333b;p=libsigrok.git diff --git a/src/resource.c b/src/resource.c index 63415930..ec32a442 100644 --- a/src/resource.c +++ b/src/resource.c @@ -102,9 +102,9 @@ static int resource_open_default(struct sr_resource *res, #ifdef FIRMWARE_DIR const char *builtindir; #endif - const char *subdir; + const char *subdir, *env; const char *const *datadirs; - FILE *file; + FILE *file = NULL; (void)cb_data; @@ -120,7 +120,15 @@ static int resource_open_default(struct sr_resource *res, return SR_ERR_ARG; } - file = try_open_file(g_get_user_data_dir(), subdir, name); + env = g_getenv("SIGROK_FIRMWARE_DIR"); + if (!env) + sr_dbg("SIGROK_FIRMWARE_DIR environment variable not set, ignoring."); + else + file = try_open_file(env, "", name); + + if (!file) + file = try_open_file(g_get_user_data_dir(), subdir, name); + /* * Scan the hard-coded directory before the system directories to * avoid picking up possibly outdated files from a system install.