AuroraRuntime/Source/Process/AuProcessEnvironment.cpp
Jamie Reece Wilson bdec6ff8ba [+] AuProcess::EnvironmentGetAll
[+] AuProcess::EnvironmentGetOne
[+] AuProcess::EnvironmentSetOne
[+] AuProcess::EnvironmentRemoveOne
[+] AuProcess::EnvironmentRemoveMany
[+] AuProcess::EnvironmentSetMany
[+] AuProcess::GetProcessStartupTimeNS
[+] AuProcess::GetProcessStartupTimeMS
[*] Note WakeOnAddress on all platforms
[*] Updated READMEs
2023-07-10 17:00:42 +01:00

63 lines
1.4 KiB
C++

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuProcessEnvironment.cpp
Date: 2023-7-10
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "AuProcessEnvironment.hpp"
namespace Aurora::Process
{
AUKN_SYM bool EnvironmentRemoveMany(const AuList<AuString> &list)
{
bool bFailed {};
for (const auto &key : list)
{
if (!EnvironmentRemoveOne(key))
{
bFailed |= true;
}
}
return !bFailed;
}
AUKN_SYM bool EnvironmentSetMany(const AuList<AuPair<AuString, AuString>> &list)
{
for (const auto &[key, value] : list)
{
if (!EnvironmentSetOne(key, value))
{
return false;
}
}
return true;
}
AuOptional<AuPair<AuString, AuString>> EnvironmentSplitString(const AuString &str)
{
auto uIdx = str.find('=');
if (uIdx == str.npos)
{
return {};
}
if (uIdx == 0)
{
// Ignore Microsoft DOS shell environment hints
// Expect to see:
// <empty>=::=::\
// (opt) <empty>=<drive letter>:=<user home>
// (opt) <empty>=ExitCode={:08x}
return {};
}
return AuMakePair(str.substr(0, uIdx), str.substr(uIdx + 1));
}
}