AuroraRuntime/Source/Process/AuProcessEnvironment.cpp

63 lines
1.4 KiB
C++
Raw Normal View History

/***
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));
}
}