diff options
author | Laszlo Ersek <lersek@redhat.com> | 2013-05-18 06:31:48 +0200 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2013-05-30 11:37:37 -0500 |
commit | e2ea3515a9d2d747f91dadf361afcbeb57a71500 (patch) | |
tree | 8ee87328e85454ee845c2896708f49c893bd71bc /util/oslib-win32.c | |
parent | 87d23f78aa79b72da022afda358bbc8a8509ca70 (diff) |
osdep: add qemu_get_local_state_pathname()
This function returns ${prefix}/var/RELATIVE_PATHNAME on POSIX-y systems,
and <CSIDL_COMMON_APPDATA>/RELATIVE_PATHNAME on Win32.
http://msdn.microsoft.com/en-us/library/bb762494.aspx
[...] This folder is used for application data that is not user
specific. For example, an application can store a spell-check
dictionary, a database of clip art, or a log file in the
CSIDL_COMMON_APPDATA folder. [...]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'util/oslib-win32.c')
-rw-r--r-- | util/oslib-win32.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c index df2ecbdffb..961fbf5e3d 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); +} |