Merge pull request #4154 from Liamolucko/check-home
Some checks failed
Build + Test / build_plus_test ([self-hosted ARMv8.0]) (push) Has been cancelled
Build + Test / build_plus_test ([self-hosted ARMv8.2]) (push) Has been cancelled
Build + Test / build_plus_test ([self-hosted ARMv8.4]) (push) Has been cancelled
GLIBC fault test / glibc_fault_test ([self-hosted ARM64]) (push) Has been cancelled
Hostrunner tests / hostrunner_tests ([self-hosted x64]) (push) Has been cancelled
Instruction Count CI run / instcountci_tests ([self-hosted ARM64]) (push) Has been cancelled
Instruction Count CI run / instcountci_tests ([self-hosted x64]) (push) Has been cancelled
Mingw build / mingw_build ([self-hosted ARM64 mingw]) (push) Has been cancelled
Mingw build / mingw_build ([self-hosted ARM64EC mingw ARM64]) (push) Has been cancelled
Vixl Simulator run / vixl_simulator ([self-hosted ARMv8.4]) (push) Has been cancelled
Vixl Simulator run / vixl_simulator ([self-hosted x64]) (push) Has been cancelled

Check if a candidate home directory exists before using it
This commit is contained in:
Ryan Houdek 2024-11-05 20:07:30 -08:00 committed by GitHub
commit e675f4241a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -439,17 +439,17 @@ const char* GetHomeDirectory() {
const char* HomeDir = getenv("HOME");
// Try to get home directory from uid
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = FindUserHomeThroughUID();
}
// try the PWD
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = getenv("PWD");
}
// Still doesn't exit? You get local
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = ".";
}