diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-04-08 09:00:22 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-04-08 09:00:22 +0200 |
commit | e73252e6d4a98631a9e5d7ea7b86b212cf857563 (patch) | |
tree | f3a675c0221f9ba1b0ff373a40b900223ef1a922 /src | |
parent | 3a16e30ed2e6322cd5b54f4c16bdaab47b268252 (diff) |
search data file in local tarball
Diffstat (limited to 'src')
-rw-r--r-- | src/gipfel.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gipfel.cxx b/src/gipfel.cxx index f10c7c3..8fbe536 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -46,7 +46,7 @@ #define DEFAULT_DATAFILE GIPFEL_DATADIR "/" PACKAGE_NAME "/gipfel.dat" char *img_file = NULL; -char *data_file = DEFAULT_DATAFILE; +char *data_file = NULL; GipfelWidget *gipf = NULL; Fl_Scroll *scroll; @@ -548,6 +548,25 @@ int main(int argc, char** argv) { if (my_argc >= 1) img_file = strdup(my_argv[0]); + if (data_file == NULL) { + struct stat sb; + + if (stat(DEFAULT_DATAFILE, &sb) == 0) { + data_file = DEFAULT_DATAFILE; + } else { + // check for gipfel.dat in local tarball + char *exec_file = strdup(argv[0]); + data_file = (char *) malloc (strlen (exec_file) + 64); + snprintf(data_file, strlen (exec_file) + 64, "%s/../gipfel.dat", + dirname(exec_file)); + free(exec_file); + if (stat(data_file, &sb) != 0) { + free(data_file); + data_file = NULL; + } + } + } + if (data_file == NULL || err) { usage(); exit(1); |