aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/invocationhistory.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-27 15:05:16 +0200
committerGitHub Enterprise <[email protected]>2026-04-27 15:05:16 +0200
commit6804dc6ff62c477399183dc85d2ad387298aa49d (patch)
treef4153a901c758b9e385627b43f1606f8c2129a04 /src/zenutil/invocationhistory.cpp
parent5.8.9-pre3 (diff)
downloadarchived-zen-6804dc6ff62c477399183dc85d2ad387298aa49d.tar.xz
archived-zen-6804dc6ff62c477399183dc85d2ad387298aa49d.zip
GetEnvVariable: return std::optional<std::string> (#1017)
- `GetEnvVariable` now returns `std::optional<std::string>` so callers can distinguish an unset variable from one set to an empty value. - Windows path uses `SetLastError(ERROR_SUCCESS)` + `ERROR_ENVVAR_NOT_FOUND` to detect "not found"; POSIX path returns `nullopt` when `getenv` returns `nullptr`. - All call sites migrated. Most use `.value_or("")` to preserve current empty-or-unset behavior. The diagnostic helpers in `zen-test/artifactprovider-tests.cpp` now report `<unset>` vs `<empty>` distinctly. - Added a check in the `ExpandEnvironmentVariables` test confirming `nullopt` for an unset variable; PATH/HOME lookups in that test use `REQUIRE(has_value())` so a missing var fails cleanly instead of throwing `bad_optional_access`.
Diffstat (limited to 'src/zenutil/invocationhistory.cpp')
-rw-r--r--src/zenutil/invocationhistory.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/zenutil/invocationhistory.cpp b/src/zenutil/invocationhistory.cpp
index 077061752..a022e4cd5 100644
--- a/src/zenutil/invocationhistory.cpp
+++ b/src/zenutil/invocationhistory.cpp
@@ -51,10 +51,10 @@ namespace {
std::filesystem::path ResolveHistoryDir()
{
#if ZEN_PLATFORM_WINDOWS
- std::string LocalAppData = GetEnvVariable("LOCALAPPDATA");
- if (!LocalAppData.empty())
+ std::optional<std::string> LocalAppData = GetEnvVariable("LOCALAPPDATA");
+ if (LocalAppData && !LocalAppData->empty())
{
- return std::filesystem::path(LocalAppData) / "Epic" / "Zen" / "History";
+ return std::filesystem::path(*LocalAppData) / "Epic" / "Zen" / "History";
}
#endif
std::filesystem::path SystemRoot = PickDefaultSystemRootDirectory();