aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-03-21 16:19:06 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-03-21 16:26:02 -0700
commit1baa7f16420a359328761b330cdaf58b82b6656c (patch)
tree03a33fe587d9b1f3ec81f9794449a5cec7e31bbd
parent9a0b2d19e32c793a9a1f0310be99af50ba211add (diff)
downloadvcpkg-1baa7f16420a359328761b330cdaf58b82b6656c.tar.gz
vcpkg-1baa7f16420a359328761b330cdaf58b82b6656c.zip
Improve error message when PROGRAMFILES is not found
-rw-r--r--toolsrc/src/vcpkg/base/system.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp
index a315c7880..60067759a 100644
--- a/toolsrc/src/vcpkg/base/system.cpp
+++ b/toolsrc/src/vcpkg/base/system.cpp
@@ -533,7 +533,15 @@ namespace vcpkg::System
static const fs::path& get_program_files()
{
- static const fs::path PATH = System::get_environment_variable("PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO);
+ static const fs::path PATH = []() -> fs::path {
+ auto value = System::get_environment_variable("PROGRAMFILES");
+ if (auto v = value.get())
+ {
+ return *v;
+ }
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Could not find PROGRAMFILES environment variable");
+ }();
+
return PATH;
}
@@ -543,7 +551,7 @@ namespace vcpkg::System
auto value = System::get_environment_variable("ProgramFiles(x86)");
if (auto v = value.get())
{
- return std::move(*v);
+ return *v;
}
return get_program_files();
}();
@@ -556,7 +564,7 @@ namespace vcpkg::System
auto value = System::get_environment_variable("ProgramW6432");
if (auto v = value.get())
{
- return std::move(*v);
+ return *v;
}
return get_program_files();
}();