summaryrefslogtreecommitdiffstats
path: root/common/homedir.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-02-01 15:27:32 +0100
committerWerner Koch <wk@gnupg.org>2015-02-01 15:27:32 +0100
commit616633b7713081ecc39419494879947cc7f163d0 (patch)
tree7647ed8e8105f47bfdf34875e16c21e9fce96be5 /common/homedir.c
parentkbx: Fix resource leak. (diff)
downloadgnupg2-616633b7713081ecc39419494879947cc7f163d0.tar.xz
gnupg2-616633b7713081ecc39419494879947cc7f163d0.zip
w32: Allow for Unicocde installation directory.
* common/homedir.c (w32_rootdir): Use Unicode fucntion not only for WinCE. -- This uses the same code We used for WindowsCE. It has not been tested with a Unicode requiring installation directory. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to '')
-rw-r--r--common/homedir.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/common/homedir.c b/common/homedir.c
index 79398411c..27141eb75 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -74,7 +74,7 @@ static int w32_portable_app;
#ifdef HAVE_W32_SYSTEM
/* This flag is true if this process' binary has been installed under
- bin and not in the root directory. */
+ bin and not in the root directory as often used before GnuPG 2.1. */
static int w32_bin_is_bin;
#endif /*HAVE_W32_SYSTEM*/
@@ -288,21 +288,15 @@ w32_rootdir (void)
{
char *p;
int rc;
+ wchar_t wdir [MAX_PATH+5];
-#ifdef HAVE_W32CE_SYSTEM
- {
- wchar_t wdir [MAX_PATH+5];
- rc = GetModuleFileName (NULL, wdir, MAX_PATH);
- if (rc && WideCharToMultiByte (CP_UTF8, 0, wdir, -1, dir, MAX_PATH-4,
- NULL, NULL) < 0)
- rc = 0;
- }
-#else
- rc = GetModuleFileName (NULL, dir, MAX_PATH);
-#endif
+ rc = GetModuleFileNameW (NULL, wdir, MAX_PATH);
+ if (rc && WideCharToMultiByte (CP_UTF8, 0, wdir, -1, dir, MAX_PATH-4,
+ NULL, NULL) < 0)
+ rc = 0;
if (!rc)
{
- log_debug ("GetModuleFileName failed: %s\n", w32_strerror (0));
+ log_debug ("GetModuleFileName failed: %s\n", w32_strerror (-1));
*dir = 0;
}
got_dir = 1;