diff --git a/wfassoc/src/lowlevel.rs b/wfassoc/src/lowlevel.rs index 83564ab..2fdd485 100644 --- a/wfassoc/src/lowlevel.rs +++ b/wfassoc/src/lowlevel.rs @@ -998,14 +998,50 @@ impl ExtKey { const NAMEOF_OPEN_WITH_PROGIDS: &str = "OpenWithProgIds"; - pub fn get_open_with_progids(&self, view: View) -> Result, Error> { - todo!() + pub fn get_open_with_progids(&self, view: View) -> Result>, Error> { + 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 { - 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::(&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( &mut self, scope: Scope, @@ -1014,6 +1050,9 @@ impl ExtKey { todo!() } + /// + /// + /// If there is no "OpenWithProgIds" subkey, this function do nothing. pub fn remove_from_open_with_progids( &mut self, scope: Scope,