blob: 8ee6b1417b0f75d84785ca263492b36d187c7d33 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include "zenutil/authutils.h"
#include "zenutil/config/commandlineoptions.h"
#include <zencore/filesystem.h>
namespace zen {
using namespace std::literals;
std::string_view
GetOidcTokenPathEnvVariableName()
{
#if ZEN_PLATFORM_WINDOWS
return "UE-OidcTokenExePath"sv;
#endif
#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
return "UE_OidcTokenExePath"sv;
#endif
}
std::filesystem::path
FindOidcTokenExePath(std::string_view OidcTokenAuthExecutablePath)
{
if (OidcTokenAuthExecutablePath.empty())
{
std::filesystem::path OidcTokenPath = GetEnvVariable(GetOidcTokenPathEnvVariableName());
if (IsFile(OidcTokenPath))
{
return OidcTokenPath;
}
const std::string OidcExecutableName = "OidcToken" ZEN_EXE_SUFFIX_LITERAL;
OidcTokenPath = (GetRunningExecutablePath().parent_path() / OidcExecutableName).make_preferred();
if (IsFile(OidcTokenPath))
{
return OidcTokenPath;
}
OidcTokenPath = (std::filesystem::current_path() / OidcExecutableName).make_preferred();
if (IsFile(OidcTokenPath))
{
return OidcTokenPath;
}
}
else
{
std::filesystem::path OidcTokenPath = std::filesystem::absolute(StringToPath(OidcTokenAuthExecutablePath)).make_preferred();
if (IsFile(OidcTokenPath))
{
return OidcTokenPath;
}
}
return {};
};
} // namespace zen
|