]> sigrok.org Git - libsigrok.git/commitdiff
resource: Also check $SIGROK_FIRMWARE_DIR for firmware files.
authorUwe Hermann <redacted>
Tue, 15 Aug 2017 20:15:47 +0000 (22:15 +0200)
committerUwe Hermann <redacted>
Tue, 15 Aug 2017 20:15:47 +0000 (22:15 +0200)
If the SIGROK_FIRMWARE_DIR environment variable is specified, look there
first for firmware files.

README.devices
src/resource.c

index 584899e2b0648ed65aae7c39cbbdf083a46db24f..3e0d5f2d089f6291de36d234a7813596b2b15889 100644 (file)
@@ -14,6 +14,7 @@ the device is connected to the PC (usually via USB), before it can be used.
 
 The default locations where libsigrok expects the firmware files are:
 
+  $SIGROK_FIRMWARE_DIR (environment variable)
   $HOME/.local/share/sigrok-firmware
   $prefix/share/sigrok-firmware
   /usr/local/share/sigrok-firmware
index 634159308ef5c057a51447e4327cc8d93c005065..ec32a4420f7755de5c5491047a756c59d56d3ba7 100644 (file)
@@ -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.