From e73252e6d4a98631a9e5d7ea7b86b212cf857563 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 8 Apr 2009 09:00:22 +0200 Subject: search data file in local tarball --- src/gipfel.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/gipfel.cxx') 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); -- cgit v1.2.3