From 299b6411732f15d152661d551ba8fc68a25ec760 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 30 Dec 2025 14:16:53 +0100 Subject: [PATCH] Implement getting full user name. --- public/common/TracySystem.cpp | 21 +++++++++++++++++++++ public/common/TracySystem.hpp | 1 + 2 files changed, 22 insertions(+) diff --git a/public/common/TracySystem.cpp b/public/common/TracySystem.cpp index 9c215795..21435080 100644 --- a/public/common/TracySystem.cpp +++ b/public/common/TracySystem.cpp @@ -13,6 +13,7 @@ # include "TracyWinFamily.hpp" #else # include +# include # include # include #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 diff --git a/public/common/TracySystem.hpp b/public/common/TracySystem.hpp index d552f852..993ae875 100644 --- a/public/common/TracySystem.hpp +++ b/public/common/TracySystem.hpp @@ -38,6 +38,7 @@ TRACY_API const char* GetThreadName( uint32_t id ); TRACY_API const char* GetEnvVar( const char* name ); TRACY_API const char* GetUserName(); +TRACY_API const char* GetUserFullName(); }