summaryrefslogtreecommitdiff
path: root/os-win32.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-06-10 11:42:23 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-06-12 08:49:14 +0300
commit355d686cf91171a148eafb604624da50179f61a6 (patch)
tree8b5382efb78741da06f5f4f5284ffc255ef2de30 /os-win32.c
parent3f26023ea0aa78d616976698148ad20ff1e4c06a (diff)
downloadqemu-355d686cf91171a148eafb604624da50179f61a6.tar.gz
qemu-355d686cf91171a148eafb604624da50179f61a6.tar.bz2
qemu-355d686cf91171a148eafb604624da50179f61a6.zip
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 <Jes.Sorensen@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Acked-by: Richard Henderson <rth@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'os-win32.c')
-rw-r--r--os-win32.c23
1 files changed, 23 insertions, 0 deletions
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;
+}