Currently we look for png files in their install directory, and we manufacture filenames with string pasting at compile time.
This new function will allow overriding the compile time setting with the env var WESTON_DATA_DIR so we can do neat tricks like allow our test suite to pass when we haven't yet installed icons system-wide. Signed-off-by: Derek Foreman <der...@osg.samsung.com> --- shared/file-util.c | 17 +++++++++++++++++ shared/file-util.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/shared/file-util.c b/shared/file-util.c index 979a3811..758c8dcc 100644 --- a/shared/file-util.c +++ b/shared/file-util.c @@ -31,6 +31,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <stdlib.h> #include "file-util.h" @@ -119,3 +120,19 @@ file_create_dated(const char *path_prefix, const char *suffix, return fdopen(fd, "w"); } + +char * +file_name_with_datadir(const char *filename) +{ + const char *base = getenv("WESTON_DATA_DIR"); + char *out; + int len; + + if (base) + len = asprintf(&out, "%s/%s", base, filename); + else + len = asprintf(&out, "%s/weston/%s", DATADIR, filename); + + if (len == -1) return NULL; + return out; +} diff --git a/shared/file-util.h b/shared/file-util.h index f639c446..dbda07a8 100644 --- a/shared/file-util.h +++ b/shared/file-util.h @@ -36,6 +36,9 @@ FILE * file_create_dated(const char *path_prefix, const char *suffix, char *name_out, size_t name_len); +char * +file_name_with_datadir(const char *); + #ifdef __cplusplus } #endif -- 2.14.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel