include: move qemu_*_exec_dir() to cutils

The function is required by get_relocated_path() (already in cutils),
and used by qemu-ga and may be generally useful.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20220525144140.591926-2-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-05-25 16:41:26 +02:00
parent 2417cbd591
commit 06680b15b4
8 changed files with 129 additions and 128 deletions

View file

@ -269,42 +269,6 @@ void qemu_set_tty_echo(int fd, bool echo)
}
}
static const char *exec_dir;
void qemu_init_exec_dir(const char *argv0)
{
char *p;
char buf[MAX_PATH];
DWORD len;
if (exec_dir) {
return;
}
len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
if (len == 0) {
return;
}
buf[len] = 0;
p = buf + len - 1;
while (p != buf && *p != '\\') {
p--;
}
*p = 0;
if (access(buf, R_OK) == 0) {
exec_dir = g_strdup(buf);
} else {
exec_dir = CONFIG_BINDIR;
}
}
const char *qemu_get_exec_dir(void)
{
return exec_dir;
}
int getpagesize(void)
{
SYSTEM_INFO system_info;