Implement getting full user name.

This commit is contained in:
Bartosz Taudul
2025-12-30 14:16:53 +01:00
parent 6933780aed
commit 299b641173
2 changed files with 22 additions and 0 deletions

View File

@@ -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