diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-24 14:44:37 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-24 14:44:37 -0800 |
| commit | 95a9a98edefe91fbcfffd53bfc4501955553de33 (patch) | |
| tree | 0256ff6c3d680148063c9f0237832b00c23ea061 /toolsrc/src/vcpkg_Environment.cpp | |
| parent | 60e67651c32060ada2a2bfd0d52366cf91ef86cb (diff) | |
| download | vcpkg-95a9a98edefe91fbcfffd53bfc4501955553de33.tar.gz vcpkg-95a9a98edefe91fbcfffd53bfc4501955553de33.zip | |
Throw error is PROGRAMFILES env variable is not found
Diffstat (limited to 'toolsrc/src/vcpkg_Environment.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_Environment.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index 527d8de89..8f3030269 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -231,6 +231,19 @@ namespace vcpkg::Environment return vcvarsall_bat; } + static fs::path find_ProgramFiles() + { + const optional<std::wstring> program_files = System::get_environmental_variable(L"PROGRAMFILES"); + Checks::check_exit(program_files.get() != nullptr, "Could not detect the PROGRAMFILES environmental variable"); + return *program_files; + } + + static const fs::path& get_ProgramFiles() + { + static const fs::path p = find_ProgramFiles(); + return p; + } + static fs::path find_ProgramFiles_32_bit() { const optional<std::wstring> program_files_X86 = System::get_environmental_variable(L"ProgramFiles(x86)"); @@ -239,7 +252,7 @@ namespace vcpkg::Environment return *program_files_X86; } - return *System::get_environmental_variable(L"PROGRAMFILES"); + return get_ProgramFiles(); } const fs::path& get_ProgramFiles_32_bit() @@ -256,7 +269,7 @@ namespace vcpkg::Environment return *program_files_W6432; } - return *System::get_environmental_variable(L"PROGRAMFILES"); + return get_ProgramFiles(); } const fs::path& get_ProgramFiles_platform_bitness() |
