summaryrefslogtreecommitdiff
path: root/libgphoto2_port
diff options
context:
space:
mode:
authorIngvar Stepanyan <me@rreverser.com>2022-09-26 11:47:02 +0100
committerGitHub <noreply@github.com>2022-09-26 12:47:02 +0200
commita3bd587689cf13a89c99f1fe7d0c1014a046835a (patch)
tree5f1c6d5b004a07357d9ffa29dcfc132470c4ecae /libgphoto2_port
parentba6c270e404a61b61c6c892c4e1d12e147c2ee9c (diff)
downloadlibgphoto2-a3bd587689cf13a89c99f1fe7d0c1014a046835a.tar.gz
Allow customizing vcamera directory at runtime (#840)
- Consumers won't have to guess the path (which depends on the version of the library). - Consumers don't have to have access to the path (/usr/share/...) might be readonly to them. - Consumer can point VCAMERADIR to a temporary directory, ensuring a clean slate before each test.
Diffstat (limited to 'libgphoto2_port')
-rw-r--r--libgphoto2_port/vusb/vcamera.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libgphoto2_port/vusb/vcamera.c b/libgphoto2_port/vusb/vcamera.c
index ed293f7d1..d2433c9dd 100644
--- a/libgphoto2_port/vusb/vcamera.c
+++ b/libgphoto2_port/vusb/vcamera.c
@@ -419,7 +419,7 @@ static struct ptp_dirent *first_dirent = NULL;
static uint32_t ptp_objectid = 0;
static void
-read_directories(char *path, struct ptp_dirent *parent) {
+read_directories(const char *path, struct ptp_dirent *parent) {
struct ptp_dirent *cur;
gp_system_dir dir;
gp_system_dirent de;
@@ -457,7 +457,7 @@ free_dirent(struct ptp_dirent *ent) {
}
static void
-read_tree(char *path) {
+read_tree(const char *path) {
struct ptp_dirent *root = NULL, *dir, *dcim = NULL;
if (first_dirent)
@@ -2157,7 +2157,8 @@ vcamera_new(vcameratype type) {
cam = calloc(1,sizeof(vcamera));
if (!cam) return NULL;
- read_tree(VCAMERADIR);
+ const char *vcameradir_env = getenv("VCAMERADIR");
+ read_tree(vcameradir_env != NULL ? vcameradir_env : VCAMERADIR);
cam->init = vcam_init;
cam->exit = vcam_exit;