resource: Also check $SIGROK_FIRMWARE_DIR for firmware files.
If the SIGROK_FIRMWARE_DIR environment variable is specified, look there first for firmware files.
This commit is contained in:
parent
dde0175d19
commit
1503d4571b
|
@ -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:
|
The default locations where libsigrok expects the firmware files are:
|
||||||
|
|
||||||
|
$SIGROK_FIRMWARE_DIR (environment variable)
|
||||||
$HOME/.local/share/sigrok-firmware
|
$HOME/.local/share/sigrok-firmware
|
||||||
$prefix/share/sigrok-firmware
|
$prefix/share/sigrok-firmware
|
||||||
/usr/local/share/sigrok-firmware
|
/usr/local/share/sigrok-firmware
|
||||||
|
|
|
@ -102,9 +102,9 @@ static int resource_open_default(struct sr_resource *res,
|
||||||
#ifdef FIRMWARE_DIR
|
#ifdef FIRMWARE_DIR
|
||||||
const char *builtindir;
|
const char *builtindir;
|
||||||
#endif
|
#endif
|
||||||
const char *subdir;
|
const char *subdir, *env;
|
||||||
const char *const *datadirs;
|
const char *const *datadirs;
|
||||||
FILE *file;
|
FILE *file = NULL;
|
||||||
|
|
||||||
(void)cb_data;
|
(void)cb_data;
|
||||||
|
|
||||||
|
@ -120,7 +120,15 @@ static int resource_open_default(struct sr_resource *res,
|
||||||
return SR_ERR_ARG;
|
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
|
* Scan the hard-coded directory before the system directories to
|
||||||
* avoid picking up possibly outdated files from a system install.
|
* avoid picking up possibly outdated files from a system install.
|
||||||
|
|
Loading…
Reference in New Issue