1
0

feat: write some content for lowlevel

This commit is contained in:
2026-05-18 16:00:29 +08:00
parent bbcea1f4d2
commit 4205ef18d3

View File

@@ -998,14 +998,50 @@ impl ExtKey {
const NAMEOF_OPEN_WITH_PROGIDS: &str = "OpenWithProgIds"; const NAMEOF_OPEN_WITH_PROGIDS: &str = "OpenWithProgIds";
pub fn get_open_with_progids(&self, view: View) -> Result<Vec<LosseProgId>, Error> { pub fn get_open_with_progids(&self, view: View) -> Result<Option<Vec<LosseProgId>>, Error> {
todo!() let key = self.open_view_for_getter(view)?;
// Get OpenWithProgIds subkey
let open_with_progids_key = match regext::try_open_subkey_with_flags(
&key,
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
PERM_R,
)? {
Some(key) => key,
None => return Ok(None),
};
// Fetch all sub-values
let key_names = regext::get_all_string_subkey_names(&open_with_progids_key)?;
// Map the result
let progids = key_names
.into_iter()
.map(|name| LosseProgId::from(name.as_str()))
.collect();
// Return value
Ok(Some(progids))
} }
///
///
/// If there is no "OpenWithProgIds" subkey, this function return false.
pub fn is_in_open_with_progids(&self, view: View, pid: &LosseProgId) -> Result<bool, Error> { pub fn is_in_open_with_progids(&self, view: View, pid: &LosseProgId) -> Result<bool, Error> {
todo!() let key = self.open_view_for_getter(view)?;
// Get OpenWithProgIds subkey
let open_with_progids_key = match regext::try_open_subkey_with_flags(
&key,
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
PERM_R,
)? {
Some(key) => key,
None => return Ok(false),
};
// Check whether there is given ProgId
Ok(regext::try_get_value::<String, _>(&open_with_progids_key, pid.to_string())?.is_some())
} }
///
///
/// If there is no "OpenWithProgIds" subkey, this function will create it first,
/// then add your given ProgId into it.
pub fn add_into_open_with_progids( pub fn add_into_open_with_progids(
&mut self, &mut self,
scope: Scope, scope: Scope,
@@ -1014,6 +1050,9 @@ impl ExtKey {
todo!() todo!()
} }
///
///
/// If there is no "OpenWithProgIds" subkey, this function do nothing.
pub fn remove_from_open_with_progids( pub fn remove_from_open_with_progids(
&mut self, &mut self,
scope: Scope, scope: Scope,