mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-15 14:22:57 -06:00
Core: GetUserName posix variant fixed, StdLogSetup now calls SyncLogPath when filepath is empty.
This commit is contained in:
parent
924e5de34a
commit
eecfa75cb5
1 changed files with 11 additions and 4 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#undef CY
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
static StaticMutex sHlock;
|
||||
|
|
@ -719,10 +721,15 @@ String GetUserName()
|
|||
::GetUserNameW(temp, &w);
|
||||
return temp;
|
||||
#else
|
||||
char user[1000];
|
||||
if(getlogin_r(user, 999))
|
||||
return user;
|
||||
return Nvl(GetEnv("USER"), "root");
|
||||
size_t bsz = 1024;
|
||||
Buffer<char> buf(bsz);
|
||||
struct passwd pwd;
|
||||
struct passwd *result = NULL;
|
||||
int rc;
|
||||
while((rc = getpwuid_r(getuid(), &pwd, buf, bsz, &result)) == ERANGE)
|
||||
buf.Alloc(bsz *= 2);
|
||||
|
||||
return rc == 0 && result ? pwd.pw_name : "";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue