From: zaxl Date: Sat, 8 Nov 2008 02:27:31 +0000 (+0000) Subject: Add:win32:Make all directories relative to the navit.exe path X-Git-Tag: navit-0.5.0.5194svn~3465 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b121f50593b29d214948c087da4d2108f713092;p=profile%2Fivi%2Fnavit.git Add:win32:Make all directories relative to the navit.exe path git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1692 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/main.c b/navit/navit/main.c index c9892f9..83953b0 100644 --- a/navit/navit/main.c +++ b/navit/navit/main.c @@ -124,7 +124,6 @@ main_remove_navit(struct navit *nav) event_main_loop_quit(); } - void main_init(char *program) { diff --git a/navit/navit/start.c b/navit/navit/start.c index 3a8539c..78130e7 100644 --- a/navit/navit/start.c +++ b/navit/navit/start.c @@ -36,7 +36,10 @@ #include "file.h" #include "search.h" #include "navit_nls.h" - +#ifdef HAVE_API_WIN32_CE +#include +#include +#endif static void print_usage(void) @@ -55,11 +58,7 @@ get_home_directory(void) if (!homedir) { dbg(0,"Could not find home directory. Using current directory as home directory."); -#ifdef _WIN32_WCE - homedir = "/Storage Card/"; -#else homedir = "."; -#endif } else { homedir=g_strdup(homedir); } @@ -70,20 +69,36 @@ static void setup_dummy_environment(void) { #ifdef HAVE_API_WIN32_CE char buf[PATH_MAX]; - /* FIXME: Get this from installation or make it a build option */ -#define NAVITCEDIR "/Storage Card/navit" - sprintf(buf, "%s", NAVITCEDIR); + wchar_t filename[MAX_PATH + 1]; + char basedir[MAX_PATH + 1]; + char *cp; + int sz; + + sz = GetModuleFileName(NULL, filename, MAX_PATH); + if (sz > 0) { + wcstombs(basedir, filename, sz + 1); + cp = strrchr(basedir,'/'); + if (!cp) + cp = strrchr(basedir,'\\'); + if (cp) + *cp = '\0'; + else + sprintf(buf, "."); + } else { + sprintf(basedir, "%s", "/Storage Card/navit"); + } + sprintf(buf, "%s", basedir); setenv("HOME", buf, 0); setenv("NAVIT_PREFIX", buf, 0); - sprintf(buf, "%s/lib", NAVITCEDIR); + sprintf(buf, "%s/lib", basedir); setenv("NAVIT_LIBDIR", buf, 0); - sprintf(buf, "%s/locale", NAVITCEDIR); + sprintf(buf, "%s/locale", basedir); setenv("NAVIT_LOCALEDIR", buf, 0); - sprintf(buf, "%s/data", NAVITCEDIR); + sprintf(buf, "%s/data", basedir); setenv("NAVIT_USER_DATADIR", buf ,0); - sprintf(buf, "%s", NAVITCEDIR); + sprintf(buf, "%s", basedir); setenv("NAVIT_SHAREDIR", buf, 0); - sprintf(buf, "%s/navit.log", NAVITCEDIR); + sprintf(buf, "%s/navit.log", basedir); setenv("NAVIT_LOGFILE", buf, 0); #endif