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

Function get_hive_from_path

lib/dsc-lib-registry/src/lib.rs:393–412  ·  view source on GitHub ↗
(path: &str)

Source from the content-addressed store, hash-verified

391}
392
393fn get_hive_from_path(path: &str) -> Result<(Hive, &str), RegistryError> {
394 // split the key path to hive and subkey otherwise it's just a hive
395 let (hive, subkey)= match path.find('\\') {
396 Some(index) => {
397 // split at index, but don't include the character at index
398 let (hive, subkey) = path.split_at(index);
399 (hive, &subkey[1..])
400 },
401 None => (path, ""),
402 };
403
404 match hive {
405 "HKCC" | "HKEY_CURRENT_CONFIG" => Ok((Hive::CurrentConfig, subkey)),
406 "HKCU" | "HKEY_CURRENT_USER" => Ok((Hive::CurrentUser, subkey)),
407 "HKCR" | "HKEY_CLASSES_ROOT" => Ok((Hive::ClassesRoot, subkey)),
408 "HKLM" | "HKEY_LOCAL_MACHINE" => Ok((Hive::LocalMachine, subkey)),
409 "HKU" | "HKEY_USERS" => Ok((Hive::Users, subkey)),
410 _ => Err(RegistryError::InvalidHive(hive.to_string()))
411 }
412}
413
414fn open_regkey(path: &str, permission: Security) -> Result<(RegKey, &str), RegistryError> {
415 let (hive, subkey) = get_hive_from_path(path)?;

Callers 4

new_from_jsonMethod · 0.85
newMethod · 0.85
removeMethod · 0.85
open_regkeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected