mirror of
https://github.com/bitwarden/browser
synced 2026-01-03 00:53:23 +00:00
* Fix double prompt when unlocking by ssh request * Add peercred for unix * Enable apple-app-store feature * Add generic parameter * Update * Add procinfo for windows * Show connecting app in ui * Use struct instead of tuple * Use atomics instead of mutex * Fix windows build * Use is_running function * Cleanup named pipe listener * Cleanups * Cargo fmt * Replace "" with none * Rebuild index.d.ts * Fix is running check
30 lines
772 B
Rust
30 lines
772 B
Rust
use anyhow::{bail, Result};
|
|
|
|
fn convert_key(key: &str) -> Result<&'static windows_registry::Key> {
|
|
Ok(match key.to_uppercase().as_str() {
|
|
"HKEY_CURRENT_USER" | "HKCU" => windows_registry::CURRENT_USER,
|
|
"HKEY_LOCAL_MACHINE" | "HKLM" => windows_registry::LOCAL_MACHINE,
|
|
"HKEY_CLASSES_ROOT" | "HKCR" => windows_registry::CLASSES_ROOT,
|
|
_ => bail!("Invalid key"),
|
|
})
|
|
}
|
|
|
|
pub fn create_key(key: &str, subkey: &str, value: &str) -> Result<()> {
|
|
let key = convert_key(key)?;
|
|
|
|
let subkey = key.create(subkey)?;
|
|
|
|
const DEFAULT: &str = "";
|
|
subkey.set_string(DEFAULT, value)?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
pub fn delete_key(key: &str, subkey: &str) -> Result<()> {
|
|
let key = convert_key(key)?;
|
|
|
|
key.remove_tree(subkey)?;
|
|
|
|
Ok(())
|
|
}
|