Move user name retrieval to a common API.

This commit is contained in:
Bartosz Taudul
2025-12-30 13:41:19 +01:00
parent 6a26472278
commit da85325686
3 changed files with 28 additions and 31 deletions

View File

@@ -336,6 +336,28 @@ TRACY_API const char* GetEnvVar( const char* name )
#endif
}
TRACY_API const char* GetUserName()
{
#if defined _WIN32
# if defined TRACY_WIN32_NO_DESKTOP
return "(?)";
# elif
DWORD userSz = UNLEN+1;
static char user[UNLEN+1];
GetUserNameA( user, &userSz );
return user;
# endif
#elif defined __ANDROID__
const auto user = getlogin();
if( user ) return user;
return "(?)";
#else
static char user[1024] = {};
getlogin_r( user, sizeof( user ) );
return user;
#endif
}
}
#ifdef __cplusplus