[Feature #19244] Windows: Prefer USERPROFILE over HOMEPATH on startup as well
This commit is contained in:
parent
77d7ac7c06
commit
9a618b95cd
@ -578,6 +578,40 @@ class TestDir < Test::Unit::TestCase
|
|||||||
ENV.delete('USERPROFILE')
|
ENV.delete('USERPROFILE')
|
||||||
assert_equal("C:/ruby/homepath", Dir.home)
|
assert_equal("C:/ruby/homepath", Dir.home)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_home_at_startup_windows
|
||||||
|
env = {'HOME' => "C:\\ruby\\home"}
|
||||||
|
args = [env]
|
||||||
|
assert_separately(args, "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
assert_equal("C:/ruby/home", Dir.home)
|
||||||
|
end;
|
||||||
|
|
||||||
|
env['USERPROFILE'] = "C:\\ruby\\userprofile"
|
||||||
|
assert_separately(args, "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
assert_equal("C:/ruby/home", Dir.home)
|
||||||
|
end;
|
||||||
|
|
||||||
|
env['HOME'] = nil
|
||||||
|
assert_separately(args, "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
assert_equal("C:/ruby/userprofile", Dir.home)
|
||||||
|
end;
|
||||||
|
|
||||||
|
env['HOMEDRIVE'] = "C:"
|
||||||
|
env['HOMEPATH'] = "\\ruby\\homepath"
|
||||||
|
assert_separately(args, "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
assert_equal("C:/ruby/userprofile", Dir.home)
|
||||||
|
end;
|
||||||
|
|
||||||
|
env['USERPROFILE'] = nil
|
||||||
|
assert_separately(args, "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
assert_equal("C:/ruby/homepath", Dir.home)
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_home
|
def test_home
|
||||||
|
@ -622,21 +622,24 @@ init_env(void)
|
|||||||
|
|
||||||
if (!GetEnvironmentVariableW(L"HOME", env, numberof(env))) {
|
if (!GetEnvironmentVariableW(L"HOME", env, numberof(env))) {
|
||||||
f = FALSE;
|
f = FALSE;
|
||||||
if (GetEnvironmentVariableW(L"HOMEDRIVE", env, numberof(env)))
|
if (GetEnvironmentVariableW(L"USERPROFILE", env, numberof(env))) {
|
||||||
len = lstrlenW(env);
|
|
||||||
else
|
|
||||||
len = 0;
|
|
||||||
if (GetEnvironmentVariableW(L"HOMEPATH", env + len, numberof(env) - len) || len) {
|
|
||||||
f = TRUE;
|
f = TRUE;
|
||||||
}
|
}
|
||||||
else if (GetEnvironmentVariableW(L"USERPROFILE", env, numberof(env))) {
|
else {
|
||||||
f = TRUE;
|
if (GetEnvironmentVariableW(L"HOMEDRIVE", env, numberof(env)))
|
||||||
}
|
len = lstrlenW(env);
|
||||||
else if (get_special_folder(CSIDL_PROFILE, env, numberof(env))) {
|
else
|
||||||
f = TRUE;
|
len = 0;
|
||||||
}
|
|
||||||
else if (get_special_folder(CSIDL_PERSONAL, env, numberof(env))) {
|
if (GetEnvironmentVariableW(L"HOMEPATH", env + len, numberof(env) - len) || len) {
|
||||||
f = TRUE;
|
f = TRUE;
|
||||||
|
}
|
||||||
|
else if (get_special_folder(CSIDL_PROFILE, env, numberof(env))) {
|
||||||
|
f = TRUE;
|
||||||
|
}
|
||||||
|
else if (get_special_folder(CSIDL_PERSONAL, env, numberof(env))) {
|
||||||
|
f = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
regulate_path(env);
|
regulate_path(env);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user