Get the home directory of the effective user ID using getpwuid() if

$HOME is not defined.
pull/16/merge
Tatsuhiro Tsujikawa 2012-03-30 01:43:38 +09:00
parent 25ef6677e9
commit e4e9562c92
1 changed files with 8 additions and 1 deletions

View File

@ -35,6 +35,8 @@
#include "util.h"
#include <signal.h>
#include <sys/types.h>
#include <pwd.h>
#include <cerrno>
#include <cassert>
@ -1008,7 +1010,12 @@ std::string getHomeDir()
}
}
}
#endif
#else // !__MINGW32__
passwd* pw = getpwuid(geteuid());
if(pw && pw->pw_dir) {
return pw->pw_dir;
}
#endif // !__MINGW32__
return A2STR::NIL;
}
}