зеркало из https://github.com/github/ruby.git
[Feature #19244] Windows: Prefer USERPROFILE over HOMEPATH on startup as well
This commit is contained in:
Родитель
77d7ac7c06
Коммит
9a618b95cd
|
@ -578,6 +578,40 @@ class TestDir < Test::Unit::TestCase
|
|||
ENV.delete('USERPROFILE')
|
||||
assert_equal("C:/ruby/homepath", Dir.home)
|
||||
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
|
||||
|
||||
def test_home
|
||||
|
|
|
@ -622,21 +622,24 @@ init_env(void)
|
|||
|
||||
if (!GetEnvironmentVariableW(L"HOME", env, numberof(env))) {
|
||||
f = FALSE;
|
||||
if (GetEnvironmentVariableW(L"HOMEDRIVE", env, numberof(env)))
|
||||
len = lstrlenW(env);
|
||||
else
|
||||
len = 0;
|
||||
if (GetEnvironmentVariableW(L"HOMEPATH", env + len, numberof(env) - len) || len) {
|
||||
if (GetEnvironmentVariableW(L"USERPROFILE", env, numberof(env))) {
|
||||
f = TRUE;
|
||||
}
|
||||
else if (GetEnvironmentVariableW(L"USERPROFILE", env, numberof(env))) {
|
||||
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;
|
||||
else {
|
||||
if (GetEnvironmentVariableW(L"HOMEDRIVE", env, numberof(env)))
|
||||
len = lstrlenW(env);
|
||||
else
|
||||
len = 0;
|
||||
|
||||
if (GetEnvironmentVariableW(L"HOMEPATH", env + len, numberof(env) - len) || len) {
|
||||
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) {
|
||||
regulate_path(env);
|
||||
|
|
Загрузка…
Ссылка в новой задаче