summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-09 02:18:59 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-09 02:18:59 +0000
commita13756ab0fa15ec8f329f549f20344a2c8ee1971 (patch)
treef607a2c604859ee6107c3d087fd4c0522f9269f7
parent361edf2c72beab05ad7f6e9633e0d59b20ed696b (diff)
downloadruby-a13756ab0fa15ec8f329f549f20344a2c8ee1971.tar.gz
ruby-a13756ab0fa15ec8f329f549f20344a2c8ee1971.tar.xz
ruby-a13756ab0fa15ec8f329f549f20344a2c8ee1971.zip
merges r21336 from trunk into ruby_1_9_1.
* win32/win32.c (init_env): use user profile folder than personal folder. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c31
2 files changed, 29 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 91e0389ca..a8170b3e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jan 5 12:52:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * win32/win32.c (init_env): use user profile folder than personal
+ folder.
+
Mon Jan 5 17:59:43 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (cygwin): needs properly implemented nl_langinfo().
diff --git a/win32/win32.c b/win32/win32.c
index 316b69b87..e518e935d 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -360,13 +360,31 @@ translate_char(char *p, int from, int to)
return p;
}
+#ifndef CSIDL_PROFILE
+#define CSIDL_PROFILE 40
+#endif
+
+static BOOL
+get_special_folder(int n, char *env)
+{
+ LPITEMIDLIST pidl;
+ LPMALLOC alloc;
+ BOOL f = FALSE;
+ if (SHGetSpecialFolderLocation(NULL, n, &pidl) == 0) {
+ f = SHGetPathFromIDList(pidl, env);
+ SHGetMalloc(&alloc);
+ alloc->lpVtbl->Free(alloc, pidl);
+ alloc->lpVtbl->Release(alloc);
+ }
+ return f;
+}
+
static void
init_env(void)
{
char env[_MAX_PATH];
DWORD len;
BOOL f;
- LPITEMIDLIST pidl;
if (!GetEnvironmentVariable("HOME", env, sizeof(env))) {
f = FALSE;
@@ -380,12 +398,11 @@ init_env(void)
else if (GetEnvironmentVariable("USERPROFILE", env, sizeof(env))) {
f = TRUE;
}
- else if (SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl) == 0) {
- LPMALLOC alloc;
- f = SHGetPathFromIDList(pidl, env);
- SHGetMalloc(&alloc);
- alloc->lpVtbl->Free(alloc, pidl);
- alloc->lpVtbl->Release(alloc);
+ else if (get_special_folder(CSIDL_PROFILE, env)) {
+ f = TRUE;
+ }
+ else if (get_special_folder(CSIDL_PERSONAL, env)) {
+ f = TRUE;
}
if (f) {
char *p = translate_char(env, '\\', '/');