mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-23 09:10:51 +00:00
Implement getting full user name.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
# include "TracyWinFamily.hpp"
|
||||
#else
|
||||
# include <pthread.h>
|
||||
# include <pwd.h>
|
||||
# include <string.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@@ -358,6 +359,26 @@ TRACY_API const char* GetUserName()
|
||||
#endif
|
||||
}
|
||||
|
||||
TRACY_API const char* GetUserFullName()
|
||||
{
|
||||
#if defined _WIN32
|
||||
return nullptr;
|
||||
#elif defined __ANDROID__
|
||||
const auto passwd = getpwuid( getuid() );
|
||||
if( passwd ) return passwd->pw_gecos;
|
||||
return nullptr;
|
||||
#else
|
||||
static char buf[4*1024];
|
||||
struct passwd pwd;
|
||||
struct passwd* ptr;
|
||||
if( getpwuid_r( getuid(), &pwd, buf, sizeof( buf ), &ptr ) == 0 && ptr == &pwd )
|
||||
{
|
||||
return pwd.pw_gecos;
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user