From 081071ccb209f4cb8bf9eba1f18dc33fac5a9394 Mon Sep 17 00:00:00 2001 From: "Eduardo Lima (Etrunko)" Date: Tue, 4 Jun 2013 13:09:56 -0300 Subject: [PATCH] edje_cc: Add -dd/--data_dir option Used for specifying the path of files specified in 'data.file' section Signed-off-by: Eduardo Lima (Etrunko) --- src/bin/edje_cc.c | 7 +++++++ src/bin/edje_cc.h | 1 + src/bin/edje_cc_handlers.c | 19 ++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/bin/edje_cc.c b/src/bin/edje_cc.c index c1368bb..9e4e9ae 100644 --- a/src/bin/edje_cc.c +++ b/src/bin/edje_cc.c @@ -15,6 +15,7 @@ Eina_Prefix *pfx = NULL; Eina_List *snd_dirs = NULL; Eina_List *img_dirs = NULL; Eina_List *fnt_dirs = NULL; +Eina_List *data_dirs = NULL; Eina_List *defines = NULL; char *file_in = NULL; char *tmp_dir = NULL; @@ -85,6 +86,7 @@ main_help(void) "-id image/directory Add a directory to look in for relative path images\n" "-fd font/directory Add a directory to look in for relative path fonts\n" "-sd sound/directory Add a directory to look in for relative path sounds samples\n" + "-dd data/directory Add a directory to look in for relative path data.file entries\n" "-td temp/directory Directory to store temporary files\n" "-v Verbose output\n" "-no-lossy Do NOT allow images to be lossy\n" @@ -175,6 +177,11 @@ main(int argc, char **argv) i++; snd_dirs = eina_list_append(snd_dirs, argv[i]); } + else if ((!strcmp(argv[i], "-dd") || !strcmp(argv[i], "--data_dir")) && (i < (argc - 1))) + { + i++; + data_dirs = eina_list_append(data_dirs, argv[i]); + } else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1))) { i++; diff --git a/src/bin/edje_cc.h b/src/bin/edje_cc.h index d9468b6..58c1f75 100644 --- a/src/bin/edje_cc.h +++ b/src/bin/edje_cc.h @@ -211,6 +211,7 @@ extern Eina_List *ext_dirs; extern Eina_List *img_dirs; extern Eina_List *fnt_dirs; extern Eina_List *snd_dirs; +extern Eina_List *data_dirs; extern char *file_in; extern char *tmp_dir; extern char *file_out; diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index 36178d2..38747c2 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -1605,9 +1605,22 @@ st_data_file(void) fd = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) { - ERR("%s:%i when opening file \"%s\": \"%s\"", - file_in, line, filename, strerror(errno)); - exit(-1); + char path[PATH_MAX], *dir; + Eina_List *l; + EINA_LIST_FOREACH(data_dirs, l, dir) + { + snprintf(path, sizeof(path), "%s/%s", dir, filename); + fd = open(path, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); + if (fd >= 0) + break; + } + + if (fd < 0) + { + ERR("%s:%i when opening file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); + exit(-1); + } } if (fstat(fd, &buf)) -- 2.7.4