mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
util: Split out exec_dir from os_find_datadir
With this change, main() calls qemu_init_exec_dir and uses argv[0] to init exec_dir. The saved value can be retrieved with qemu_get_exec_dir later. It will be reused by module loading. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
46eef33b89
commit
10f5bff622
10 changed files with 108 additions and 56 deletions
21
os-win32.c
21
os-win32.c
|
@ -84,26 +84,9 @@ 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 *os_find_datadir(void)
|
||||
{
|
||||
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 g_strdup(buf);
|
||||
}
|
||||
return NULL;
|
||||
return qemu_get_exec_dir();
|
||||
}
|
||||
|
||||
void os_set_line_buffering(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue