From 6170540b824635a29eb7a0360affac9394c84c52 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 10 Jun 2010 11:42:23 +0200 Subject: Move find_datadir to OS specific files. This moves the win32 and POSIX versions of find_datadir() to OS specific files, and removes some #ifdef clutter from vl.c Signed-off-by: Jes Sorensen Acked-by: Juan Quintela Acked-by: Richard Henderson Signed-off-by: Blue Swirl --- os-win32.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'os-win32.c') diff --git a/os-win32.c b/os-win32.c index a936f7ad22..17585385c3 100644 --- a/os-win32.c +++ b/os-win32.c @@ -181,3 +181,26 @@ void os_setup_early_signal_handling(void) } } } + +/* Look for support files in the same directory as the executable. */ +char *os_find_datadir(const char *argv0) +{ + char *p; + char buf[MAX_PATH]; + DWORD len; + + len = GetModuleFileName(NULL, buf, sizeof(buf) - 1); + if (len == 0) { + return NULL; + } + + buf[len] = 0; + p = buf + len - 1; + while (p != buf && *p != '\\') + p--; + *p = 0; + if (access(buf, R_OK) == 0) { + return qemu_strdup(buf); + } + return NULL; +} -- cgit v1.2.1