Skip to content

Commit

Permalink
xrCore: implement getting uesrname and machinename on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Nov 6, 2018
1 parent 46ba394 commit 33d1ba0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <mmsystem.h>
#include <objbase.h>
#pragma comment(lib, "winmm.lib")
#elif defined(LINUX)
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#endif
#include "xrCore.h"
#include "Threading/ThreadPool.hpp"
Expand Down Expand Up @@ -237,6 +241,20 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, LogCallback c

DWORD sz_comp = sizeof(CompName);
GetComputerName(CompName, &sz_comp);
#elif defined(LINUX)
uid_t uid = geteuid();
struct passwd *pw = getpwuid(uid);
if(pw)
{
strcpy(UserName, pw->pw_gecos);
char* pos = strchr(UserName, ','); // pw_gecos return string
if(NULL != pos)
*pos = 0;
if(0 == UserName[0])
strcpy(UserName, pw->pw_name);
}

gethostname(CompName, sizeof(CompName));
#endif

Memory._initialize();
Expand Down

0 comments on commit 33d1ba0

Please sign in to comment.