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>
This commit is contained in:
parent
8d963e6ae7
commit
6170540b82
4 changed files with 90 additions and 90 deletions
23
os-win32.c
23
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue