MCPcopy Create free account
hub / github.com/PowerShell/DSC / get

Method get

tools/dsctest/src/refresh_env.rs:38–66  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

36 }
37
38 pub fn get(&self) -> RefreshEnv {
39 #[cfg(windows)]
40 {
41 // Get the environment variable from the registry for current user
42 let hkcu = Hive::CurrentUser.open("Environment", Security::Read).unwrap();
43 if let Ok(Data::String(value) | Data::ExpandString(value)) = hkcu.value(&self.name) {
44 return RefreshEnv {
45 metadata: None,
46 name: self.name.clone(),
47 value: value.to_string_lossy(),
48 };
49 }
50
51 RefreshEnv {
52 metadata: None,
53 name: self.name.clone(),
54 value: String::new(),
55 }
56 }
57 #[cfg(not(windows))]
58 {
59 // Return the input value on non-Windows since we can't read from the registry
60 RefreshEnv {
61 metadata: None,
62 name: self.name.clone(),
63 value: self.value.clone(),
64 }
65 }
66 }
67}

Callers 1

mainFunction · 0.45

Calls 2

newFunction · 0.50
openMethod · 0.45

Tested by

no test coverage detected