(path: &str)
| 391 | } |
| 392 | |
| 393 | fn 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 | |
| 414 | fn open_regkey(path: &str, permission: Security) -> Result<(RegKey, &str), RegistryError> { |
| 415 | let (hive, subkey) = get_hive_from_path(path)?; |
no outgoing calls
no test coverage detected