diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/oslib-posix.c | 9 | ||||
-rw-r--r-- | util/oslib-win32.c | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 631a1de..3dc8b1b 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -47,6 +47,8 @@ extern int daemon(int, int); # define QEMU_VMALLOC_ALIGN getpagesize() #endif +#include <glib/gprintf.h> + #include "config-host.h" #include "sysemu/sysemu.h" #include "trace.h" @@ -232,3 +234,10 @@ int qemu_utimens(const char *path, const struct timespec *times) return utimes(path, &tv[0]); } + +char * +qemu_get_local_state_pathname(const char *relative_pathname) +{ + return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR, + relative_pathname); +} diff --git a/util/oslib-win32.c b/util/oslib-win32.c index df2ecbd..961fbf5 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -26,12 +26,17 @@ * THE SOFTWARE. */ #include <windows.h> +#include <glib.h> +#include <stdlib.h> #include "config-host.h" #include "sysemu/sysemu.h" #include "qemu/main-loop.h" #include "trace.h" #include "qemu/sockets.h" +/* this must come after including "trace.h" */ +#include <shlobj.h> + void *qemu_oom_check(void *ptr) { if (ptr == NULL) { @@ -160,3 +165,20 @@ int qemu_get_thread_id(void) { return GetCurrentThreadId(); } + +char * +qemu_get_local_state_pathname(const char *relative_pathname) +{ + HRESULT result; + char base_path[MAX_PATH+1] = ""; + + result = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, + /* SHGFP_TYPE_CURRENT */ 0, base_path); + if (result != S_OK) { + /* misconfigured environment */ + g_critical("CSIDL_COMMON_APPDATA unavailable: %ld", (long)result); + abort(); + } + return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", base_path, + relative_pathname); +} |