You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Linux: added missing FPlatformProcess::UserName() implementation.
(Merging CL 2651396 from FN to main).
[CL 2651542 by Dmitry Rekman in Main branch]
This commit is contained in:
committed by
Dmitry.Rekman@epicgames.com
parent
2d7dcaef1b
commit
e2314bbb8b
@@ -96,7 +96,7 @@ void FLinuxPlatformMisc::NormalizePath(FString& InPath)
|
||||
// if var failed
|
||||
if (!bHaveHome)
|
||||
{
|
||||
struct passwd * UserInfo = getpwuid(getuid());
|
||||
struct passwd * UserInfo = getpwuid(geteuid());
|
||||
if (NULL != UserInfo && NULL != UserInfo->pw_dir)
|
||||
{
|
||||
FCString::Strcpy(CachedResult, ARRAY_COUNT(CachedResult) - 1, ANSI_TO_TCHAR(UserInfo->pw_dir));
|
||||
@@ -128,6 +128,7 @@ void FLinuxPlatformMisc::PlatformInit()
|
||||
UE_LOG(LogInit, Log, TEXT(" - this process' id (pid) is %d, parent process' id (ppid) is %d"), static_cast< int32 >(getpid()), static_cast< int32 >(getppid()));
|
||||
UE_LOG(LogInit, Log, TEXT(" - we are %srunning under debugger"), IsDebuggerPresent() ? TEXT("") : TEXT("not "));
|
||||
UE_LOG(LogInit, Log, TEXT(" - machine network name is '%s'"), FPlatformProcess::ComputerName());
|
||||
UE_LOG(LogInit, Log, TEXT(" - user name is '%s' (%s)"), FPlatformProcess::UserName(), FPlatformProcess::UserName(false));
|
||||
UE_LOG(LogInit, Log, TEXT(" - we're logged in %s"), FPlatformMisc::HasBeenStartedRemotely() ? TEXT("remotely") : TEXT("locally"));
|
||||
UE_LOG(LogInit, Log, TEXT(" - Number of physical cores available for the process: %d"), FPlatformMisc::NumberOfCores());
|
||||
UE_LOG(LogInit, Log, TEXT(" - Number of logical cores available for the process: %d"), FPlatformMisc::NumberOfCoresIncludingHyperthreads());
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace PlatformProcessLimits
|
||||
{
|
||||
MaxComputerName = 128,
|
||||
MaxBaseDirLength= MAX_PATH + 1,
|
||||
MaxArgvParameters = 256
|
||||
MaxArgvParameters = 256,
|
||||
MaxUserName = LOGIN_NAME_MAX
|
||||
};
|
||||
};
|
||||
|
||||
@@ -149,6 +150,45 @@ const TCHAR* FLinuxPlatformProcess::BaseDir()
|
||||
return CachedResult;
|
||||
}
|
||||
|
||||
const TCHAR* FLinuxPlatformProcess::UserName(bool bOnlyAlphaNumeric)
|
||||
{
|
||||
static TCHAR Name[PlatformProcessLimits::MaxUserName] = { 0 };
|
||||
static bool bHaveResult = false;
|
||||
|
||||
if (!bHaveResult)
|
||||
{
|
||||
struct passwd * UserInfo = getpwuid(geteuid());
|
||||
if (nullptr != UserInfo && nullptr != UserInfo->pw_name)
|
||||
{
|
||||
FString TempName(UTF8_TO_TCHAR(UserInfo->pw_name));
|
||||
if (bOnlyAlphaNumeric)
|
||||
{
|
||||
const TCHAR *Src = *TempName;
|
||||
TCHAR * Dst = Name;
|
||||
for (; *Src != 0 && (Dst - Name) < ARRAY_COUNT(Name) - 1; ++Src)
|
||||
{
|
||||
if (FChar::IsAlnum(*Src))
|
||||
{
|
||||
*Dst++ = *Src;
|
||||
}
|
||||
}
|
||||
*Dst++ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FCString::Strncpy(Name, *TempName, ARRAY_COUNT(Name) - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FCString::Sprintf(Name, TEXT("euid%d"), geteuid());
|
||||
}
|
||||
bHaveResult = true;
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
const TCHAR* FLinuxPlatformProcess::UserDir()
|
||||
{
|
||||
// The UserDir is where user visible files (such as game projects) live.
|
||||
|
||||
@@ -247,6 +247,7 @@ struct CORE_API FLinuxPlatformProcess : public FGenericPlatformProcess
|
||||
static const TCHAR* ComputerName();
|
||||
static void CleanFileCache();
|
||||
static const TCHAR* BaseDir();
|
||||
static const TCHAR* UserName(bool bOnlyAlphaNumeric = true);
|
||||
static const TCHAR* UserDir();
|
||||
static const TCHAR* UserSettingsDir();
|
||||
static const TCHAR* ApplicationSettingsDir();
|
||||
|
||||
Reference in New Issue
Block a user