summaryrefslogtreecommitdiff
path: root/navit/start.c
diff options
context:
space:
mode:
authorzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-11-08 02:27:31 +0000
committerzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-11-08 02:27:31 +0000
commit2318dd8c0d4a853f611c48f980f2b9366c826233 (patch)
tree1d440425cd511bd8418c14b93bf5a6b970520f4c /navit/start.c
parent753061b174a0ba5a0dd00a0f4b0aac511520bd79 (diff)
downloadnavit-2318dd8c0d4a853f611c48f980f2b9366c826233.tar.gz
Add:win32:Make all directories relative to the navit.exe path
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1692 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/start.c')
-rw-r--r--navit/start.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/navit/start.c b/navit/start.c
index 3a8539c00..78130e71c 100644
--- a/navit/start.c
+++ b/navit/start.c
@@ -36,7 +36,10 @@
#include "file.h"
#include "search.h"
#include "navit_nls.h"
-
+#ifdef HAVE_API_WIN32_CE
+#include <windows.h>
+#include <winbase.h>
+#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