1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* win32/win32.c (init_env): use user profile folder than personal

folder.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-01-05 03:52:11 +00:00
parent 8b7b9e33a5
commit 97826efddd
2 changed files with 29 additions and 7 deletions

View file

@ -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 08:41:13 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* file.c (rb_file_s_stat): need type check for non string values.

View file

@ -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, '\\', '/');