PathVariable.h (1071B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include "winget/Manifest.h" 5 #include "winget/Registry.h" 6 7 namespace AppInstaller::Registry::Environment 8 { 9 bool RefreshPathVariableForCurrentProcess(); 10 11 struct PathVariable 12 { 13 PathVariable(Manifest::ScopeEnum scope, bool readOnly = false); 14 15 // Returns the PATH variable as a string. 16 std::string GetPathValue(); 17 18 // Checks if the PATH variable contains the target path. 19 bool Contains(const std::filesystem::path& target); 20 21 // Returns a value indicating whether the target path was removed from the PATH variable. 22 bool Remove(const std::filesystem::path& target); 23 24 // Returns a value indicating whether the target path was appended to the PATH variable. 25 bool Append(const std::filesystem::path& target); 26 27 private: 28 void SetPathValue(const std::string& value); 29 Registry::Key m_key; 30 Manifest::ScopeEnum m_scope; 31 bool m_readOnly; 32 }; 33 }