fix: update blank guard usage and fix issue
This commit is contained in:
@@ -77,6 +77,7 @@ default = '@C:\path\to\ppic.exe,-1001'
|
|||||||
|
|
||||||
# And more string resources...
|
# And more string resources...
|
||||||
jpg = '@C:\path\to\ppic.exe,-1011'
|
jpg = '@C:\path\to\ppic.exe,-1011'
|
||||||
|
jfif = '@C:\path\to\ppic.exe,-1050'
|
||||||
gif = '@C:\path\to\ppic.exe,-1012'
|
gif = '@C:\path\to\ppic.exe,-1012'
|
||||||
bmp = '@C:\path\to\ppic.exe,-1013'
|
bmp = '@C:\path\to\ppic.exe,-1013'
|
||||||
png = '@C:\path\to\ppic.exe,-1014'
|
png = '@C:\path\to\ppic.exe,-1014'
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ fn run_ext_list(
|
|||||||
pub fn run(c: cli::Cli) -> Result<()> {
|
pub fn run(c: cli::Cli) -> Result<()> {
|
||||||
// Read manifest file first
|
// Read manifest file first
|
||||||
let mf = manifest::Manifest::from_file(Path::new(&c.manifest_file))?;
|
let mf = manifest::Manifest::from_file(Path::new(&c.manifest_file))?;
|
||||||
println!("{:?}", mf);
|
|
||||||
// Parse it into schema
|
// Parse it into schema
|
||||||
let schema = mf.into_schema()?;
|
let schema = mf.into_schema()?;
|
||||||
// Parse it into program
|
// Parse it into program
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ impl AppPathsKey {
|
|||||||
OpenKeyTerritory::Hybrid => panic!("unexpected hybrid key territory"),
|
OpenKeyTerritory::Hybrid => panic!("unexpected hybrid key territory"),
|
||||||
};
|
};
|
||||||
// navigate to App Paths
|
// navigate to App Paths
|
||||||
let app_paths =
|
let app_paths = hk.open_subkey_with_flags(Self::APP_PATHS, perms)?;
|
||||||
hk.open_subkey_with_flags(regext::blank_path_guard(Self::APP_PATHS)?, perms)?;
|
|
||||||
// open file name key if possible
|
// open file name key if possible
|
||||||
let this_app = regext::try_open_subkey_with_flags(
|
let this_app = regext::try_open_subkey_with_flags(
|
||||||
&app_paths,
|
&app_paths,
|
||||||
|
|||||||
@@ -40,14 +40,12 @@ impl ApplicationsKey {
|
|||||||
OpenKeyTerritory::Hybrid => RegKey::predef(HKEY_CLASSES_ROOT),
|
OpenKeyTerritory::Hybrid => RegKey::predef(HKEY_CLASSES_ROOT),
|
||||||
};
|
};
|
||||||
let applications = match territory {
|
let applications = match territory {
|
||||||
OpenKeyTerritory::User | OpenKeyTerritory::System => hk.open_subkey_with_flags(
|
OpenKeyTerritory::User | OpenKeyTerritory::System => {
|
||||||
regext::blank_path_guard(Self::FULL_APPLICATIONS)?,
|
hk.open_subkey_with_flags(Self::FULL_APPLICATIONS, perms)?
|
||||||
perms,
|
}
|
||||||
)?,
|
OpenKeyTerritory::Hybrid => {
|
||||||
OpenKeyTerritory::Hybrid => hk.open_subkey_with_flags(
|
hk.open_subkey_with_flags(Self::PARTIAL_APPLICATIONS, perms)?
|
||||||
regext::blank_path_guard(Self::PARTIAL_APPLICATIONS)?,
|
}
|
||||||
perms,
|
|
||||||
)?,
|
|
||||||
};
|
};
|
||||||
// open app key if possible
|
// open app key if possible
|
||||||
let this_app = regext::try_open_subkey_with_flags(
|
let this_app = regext::try_open_subkey_with_flags(
|
||||||
@@ -117,7 +115,7 @@ impl ApplicationsKey {
|
|||||||
// Get shell subkey
|
// Get shell subkey
|
||||||
let shell_key = match regext::try_open_subkey_with_flags(
|
let shell_key = match regext::try_open_subkey_with_flags(
|
||||||
&key,
|
&key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?,
|
Self::NAMEOF_SHELL_VERB_PART1,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -139,7 +137,7 @@ impl ApplicationsKey {
|
|||||||
// Get command subkey.
|
// Get command subkey.
|
||||||
let command_key = match regext::try_open_subkey_with_flags(
|
let command_key = match regext::try_open_subkey_with_flags(
|
||||||
&verb_key,
|
&verb_key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART3)?,
|
Self::NAMEOF_SHELL_VERB_PART3,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -167,24 +165,20 @@ impl ApplicationsKey {
|
|||||||
match sv {
|
match sv {
|
||||||
Some(sv) => {
|
Some(sv) => {
|
||||||
// Create shell subkey
|
// Create shell subkey
|
||||||
let (shell_key, _) = key.create_subkey_with_flags(
|
let (shell_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?,
|
key.create_subkey_with_flags(Self::NAMEOF_SHELL_VERB_PART1, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Create verb key
|
// Create verb key
|
||||||
let (verb_key, _) =
|
let (verb_key, _) =
|
||||||
shell_key.create_subkey_with_flags(sv.get_verb().inner(), PERM_RW)?;
|
shell_key.create_subkey_with_flags(sv.get_verb().inner(), PERM_RW)?;
|
||||||
// Create command key
|
// Create command key
|
||||||
let (command_key, _) = verb_key.create_subkey_with_flags(
|
let (command_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART3)?,
|
verb_key.create_subkey_with_flags(Self::NAMEOF_SHELL_VERB_PART3, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Set command key default value
|
// Set command key default value
|
||||||
command_key.set_value(Self::NAMEOF_SHELL_VERB_PART4, &sv.get_command().full())?;
|
command_key.set_value(Self::NAMEOF_SHELL_VERB_PART4, &sv.get_command().full())?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Delete shell and its all subkey.
|
// Delete shell and its all subkey.
|
||||||
key.delete_subkey_all(regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?)?;
|
key.delete_subkey_all(Self::NAMEOF_SHELL_VERB_PART1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +193,7 @@ impl ApplicationsKey {
|
|||||||
// Get default icon subkey
|
// Get default icon subkey
|
||||||
let default_icon_key = match regext::try_open_subkey_with_flags(
|
let default_icon_key = match regext::try_open_subkey_with_flags(
|
||||||
&key,
|
&key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?,
|
Self::NAMEOF_DEFAULT_ICON_PART1,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -218,16 +212,14 @@ impl ApplicationsKey {
|
|||||||
match icon {
|
match icon {
|
||||||
Some(icon) => {
|
Some(icon) => {
|
||||||
// Create default icon subkey
|
// Create default icon subkey
|
||||||
let (default_icon_key, _) = key.create_subkey_with_flags(
|
let (default_icon_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?,
|
key.create_subkey_with_flags(Self::NAMEOF_DEFAULT_ICON_PART1, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Set default value of default icon subkey.
|
// Set default value of default icon subkey.
|
||||||
default_icon_key.set_value(Self::NAMEOF_DEFAULT_ICON_PART2, &icon.to_string())?;
|
default_icon_key.set_value(Self::NAMEOF_DEFAULT_ICON_PART2, &icon.to_string())?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Delete shell and its all subkey.
|
// Delete shell and its all subkey.
|
||||||
key.delete_subkey_all(regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?)?;
|
key.delete_subkey_all(Self::NAMEOF_DEFAULT_ICON_PART1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,11 +262,8 @@ impl ApplicationsKey {
|
|||||||
pub fn get_supported_types(&self, view: View) -> Result<Option<Vec<concept::Ext>>> {
|
pub fn get_supported_types(&self, view: View) -> Result<Option<Vec<concept::Ext>>> {
|
||||||
let key = self.open_view_for_getter(view)?;
|
let key = self.open_view_for_getter(view)?;
|
||||||
// Get supported types subkey
|
// Get supported types subkey
|
||||||
let supported_types_key = match regext::try_open_subkey_with_flags(
|
let supported_types_key =
|
||||||
&key,
|
match regext::try_open_subkey_with_flags(&key, Self::NAMEOF_SUPPORTED_TYPES, PERM_R)? {
|
||||||
regext::blank_path_guard(Self::NAMEOF_SUPPORTED_TYPES)?,
|
|
||||||
PERM_R,
|
|
||||||
)? {
|
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
};
|
};
|
||||||
@@ -299,20 +288,19 @@ impl ApplicationsKey {
|
|||||||
match tys {
|
match tys {
|
||||||
Some(tys) => {
|
Some(tys) => {
|
||||||
// Create supported types key
|
// Create supported types key
|
||||||
let (supported_types_key, _) = key.create_subkey_with_flags(
|
let (supported_types_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_SUPPORTED_TYPES)?,
|
key.create_subkey_with_flags(Self::NAMEOF_SUPPORTED_TYPES, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Clean all contents of this key
|
// Clean all contents of this key
|
||||||
regext::clean_all_contents(&supported_types_key)?;
|
regext::clean_all_contents(&supported_types_key)?;
|
||||||
// Add file types one by one
|
// Add file types one by one
|
||||||
for ty in tys {
|
for ty in tys {
|
||||||
supported_types_key.set_value(ty.dotted_inner(), &"")?;
|
supported_types_key
|
||||||
|
.set_value(regext::blank_path_guard(ty.dotted_inner())?, &"")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Delete this subkey.
|
// Delete this subkey.
|
||||||
key.delete_subkey_all(regext::blank_path_guard(Self::NAMEOF_SUPPORTED_TYPES)?)?;
|
key.delete_subkey_all(Self::NAMEOF_SUPPORTED_TYPES)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,9 @@ impl ExtKey {
|
|||||||
};
|
};
|
||||||
let classes = match territory {
|
let classes = match territory {
|
||||||
OpenKeyTerritory::User | OpenKeyTerritory::System => {
|
OpenKeyTerritory::User | OpenKeyTerritory::System => {
|
||||||
hk.open_subkey_with_flags(regext::blank_path_guard(Self::FULL_CLASSES)?, perms)?
|
hk.open_subkey_with_flags(Self::FULL_CLASSES, perms)?
|
||||||
}
|
|
||||||
OpenKeyTerritory::Hybrid => {
|
|
||||||
hk.open_subkey_with_flags(regext::blank_path_guard(Self::PARTIAL_CLASSES)?, perms)?
|
|
||||||
}
|
}
|
||||||
|
OpenKeyTerritory::Hybrid => hk.open_subkey_with_flags(Self::PARTIAL_CLASSES, perms)?,
|
||||||
};
|
};
|
||||||
// open extension key if possible
|
// open extension key if possible
|
||||||
let this_ext = regext::try_open_subkey_with_flags(
|
let this_ext = regext::try_open_subkey_with_flags(
|
||||||
@@ -141,11 +139,9 @@ impl ExtKey {
|
|||||||
pub fn get_open_with_progids(&self, view: View) -> Result<Option<Vec<LosseProgId>>> {
|
pub fn get_open_with_progids(&self, view: View) -> Result<Option<Vec<LosseProgId>>> {
|
||||||
let key = self.open_view_for_getter(view)?;
|
let key = self.open_view_for_getter(view)?;
|
||||||
// Get OpenWithProgIds subkey
|
// Get OpenWithProgIds subkey
|
||||||
let open_with_progids_key = match regext::try_open_subkey_with_flags(
|
let open_with_progids_key =
|
||||||
&key,
|
match regext::try_open_subkey_with_flags(&key, Self::NAMEOF_OPEN_WITH_PROGIDS, PERM_R)?
|
||||||
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
|
{
|
||||||
PERM_R,
|
|
||||||
)? {
|
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
};
|
};
|
||||||
@@ -166,16 +162,18 @@ impl ExtKey {
|
|||||||
pub fn is_in_open_with_progids(&self, view: View, pid: &LosseProgId) -> Result<bool> {
|
pub fn is_in_open_with_progids(&self, view: View, pid: &LosseProgId) -> Result<bool> {
|
||||||
let key = self.open_view_for_getter(view)?;
|
let key = self.open_view_for_getter(view)?;
|
||||||
// Get OpenWithProgIds subkey
|
// Get OpenWithProgIds subkey
|
||||||
let open_with_progids_key = match regext::try_open_subkey_with_flags(
|
let open_with_progids_key =
|
||||||
&key,
|
match regext::try_open_subkey_with_flags(&key, Self::NAMEOF_OPEN_WITH_PROGIDS, PERM_R)?
|
||||||
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
|
{
|
||||||
PERM_R,
|
|
||||||
)? {
|
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
None => return Ok(false),
|
None => return Ok(false),
|
||||||
};
|
};
|
||||||
// Check whether there is given ProgId
|
// Check whether there is given ProgId
|
||||||
Ok(regext::try_get_value::<String, _>(&open_with_progids_key, pid.to_string())?.is_some())
|
Ok(regext::try_get_value::<String, _>(
|
||||||
|
&open_with_progids_key,
|
||||||
|
regext::blank_path_guard(pid.to_string())?,
|
||||||
|
)?
|
||||||
|
.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -185,12 +183,10 @@ impl ExtKey {
|
|||||||
pub fn add_into_open_with_progids(&mut self, scope: Scope, pid: &LosseProgId) -> Result<()> {
|
pub fn add_into_open_with_progids(&mut self, scope: Scope, pid: &LosseProgId) -> Result<()> {
|
||||||
let key = self.open_scope_for_setter(scope)?;
|
let key = self.open_scope_for_setter(scope)?;
|
||||||
// Get subkey
|
// Get subkey
|
||||||
let (open_with_progids_key, _) = key.create_subkey_with_flags(
|
let (open_with_progids_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
|
key.create_subkey_with_flags(Self::NAMEOF_OPEN_WITH_PROGIDS, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Add value
|
// Add value
|
||||||
open_with_progids_key.set_value(pid.to_string(), &"")?;
|
open_with_progids_key.set_value(regext::blank_path_guard(pid.to_string())?, &"")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +198,7 @@ impl ExtKey {
|
|||||||
// Try get subkey
|
// Try get subkey
|
||||||
let open_with_progids_key = match regext::try_open_subkey_with_flags(
|
let open_with_progids_key = match regext::try_open_subkey_with_flags(
|
||||||
&key,
|
&key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_OPEN_WITH_PROGIDS)?,
|
Self::NAMEOF_OPEN_WITH_PROGIDS,
|
||||||
PERM_RW,
|
PERM_RW,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
|
|||||||
@@ -41,11 +41,9 @@ impl ProgIdKey {
|
|||||||
};
|
};
|
||||||
let classes = match territory {
|
let classes = match territory {
|
||||||
OpenKeyTerritory::User | OpenKeyTerritory::System => {
|
OpenKeyTerritory::User | OpenKeyTerritory::System => {
|
||||||
hk.open_subkey_with_flags(regext::blank_path_guard(Self::FULL_CLASSES)?, perms)?
|
hk.open_subkey_with_flags(Self::FULL_CLASSES, perms)?
|
||||||
}
|
|
||||||
OpenKeyTerritory::Hybrid => {
|
|
||||||
hk.open_subkey_with_flags(regext::blank_path_guard(Self::PARTIAL_CLASSES)?, perms)?
|
|
||||||
}
|
}
|
||||||
|
OpenKeyTerritory::Hybrid => hk.open_subkey_with_flags(Self::PARTIAL_CLASSES, perms)?,
|
||||||
};
|
};
|
||||||
// open ProgId key if possible
|
// open ProgId key if possible
|
||||||
let this_progid = regext::try_open_subkey_with_flags(
|
let this_progid = regext::try_open_subkey_with_flags(
|
||||||
@@ -148,7 +146,7 @@ impl ProgIdKey {
|
|||||||
// Get shell subkey
|
// Get shell subkey
|
||||||
let shell_key = match regext::try_open_subkey_with_flags(
|
let shell_key = match regext::try_open_subkey_with_flags(
|
||||||
&key,
|
&key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?,
|
Self::NAMEOF_SHELL_VERB_PART1,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -170,7 +168,7 @@ impl ProgIdKey {
|
|||||||
// Get command subkey.
|
// Get command subkey.
|
||||||
let command_key = match regext::try_open_subkey_with_flags(
|
let command_key = match regext::try_open_subkey_with_flags(
|
||||||
&verb_key,
|
&verb_key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART3)?,
|
Self::NAMEOF_SHELL_VERB_PART3,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -198,24 +196,20 @@ impl ProgIdKey {
|
|||||||
match sv {
|
match sv {
|
||||||
Some(sv) => {
|
Some(sv) => {
|
||||||
// Create shell subkey
|
// Create shell subkey
|
||||||
let (shell_key, _) = key.create_subkey_with_flags(
|
let (shell_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?,
|
key.create_subkey_with_flags(Self::NAMEOF_SHELL_VERB_PART1, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Create verb key
|
// Create verb key
|
||||||
let (verb_key, _) =
|
let (verb_key, _) =
|
||||||
shell_key.create_subkey_with_flags(sv.get_verb().inner(), PERM_RW)?;
|
shell_key.create_subkey_with_flags(sv.get_verb().inner(), PERM_RW)?;
|
||||||
// Create command key
|
// Create command key
|
||||||
let (command_key, _) = verb_key.create_subkey_with_flags(
|
let (command_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART3)?,
|
verb_key.create_subkey_with_flags(Self::NAMEOF_SHELL_VERB_PART3, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Set command key default value
|
// Set command key default value
|
||||||
command_key.set_value(Self::NAMEOF_SHELL_VERB_PART4, &sv.get_command().full())?;
|
command_key.set_value(Self::NAMEOF_SHELL_VERB_PART4, &sv.get_command().full())?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Delete shell and its all subkey.
|
// Delete shell and its all subkey.
|
||||||
key.delete_subkey_all(regext::blank_path_guard(Self::NAMEOF_SHELL_VERB_PART1)?)?;
|
key.delete_subkey_all(Self::NAMEOF_SHELL_VERB_PART1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +258,7 @@ impl ProgIdKey {
|
|||||||
// Get default icon subkey
|
// Get default icon subkey
|
||||||
let default_icon_key = match regext::try_open_subkey_with_flags(
|
let default_icon_key = match regext::try_open_subkey_with_flags(
|
||||||
&key,
|
&key,
|
||||||
regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?,
|
Self::NAMEOF_DEFAULT_ICON_PART1,
|
||||||
PERM_R,
|
PERM_R,
|
||||||
)? {
|
)? {
|
||||||
Some(key) => key,
|
Some(key) => key,
|
||||||
@@ -283,16 +277,14 @@ impl ProgIdKey {
|
|||||||
match icon {
|
match icon {
|
||||||
Some(icon) => {
|
Some(icon) => {
|
||||||
// Create default icon subkey
|
// Create default icon subkey
|
||||||
let (default_icon_key, _) = key.create_subkey_with_flags(
|
let (default_icon_key, _) =
|
||||||
regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?,
|
key.create_subkey_with_flags(Self::NAMEOF_DEFAULT_ICON_PART1, PERM_RW)?;
|
||||||
PERM_RW,
|
|
||||||
)?;
|
|
||||||
// Set default value of default icon subkey.
|
// Set default value of default icon subkey.
|
||||||
default_icon_key.set_value(Self::NAMEOF_DEFAULT_ICON_PART2, &icon.to_string())?;
|
default_icon_key.set_value(Self::NAMEOF_DEFAULT_ICON_PART2, &icon.to_string())?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Delete shell and its all subkey.
|
// Delete shell and its all subkey.
|
||||||
key.delete_subkey_all(regext::blank_path_guard(Self::NAMEOF_DEFAULT_ICON_PART1)?)?;
|
key.delete_subkey_all(Self::NAMEOF_DEFAULT_ICON_PART1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ impl BlankPathError {
|
|||||||
/// Because it will cause unexpected behavior that returning key self, rather than subkey.
|
/// Because it will cause unexpected behavior that returning key self, rather than subkey.
|
||||||
/// This is VERY dangerous especially for those registry delete functions.
|
/// This is VERY dangerous especially for those registry delete functions.
|
||||||
/// So I create this function to prevent any harmful blank path was passed into registry function.
|
/// So I create this function to prevent any harmful blank path was passed into registry function.
|
||||||
|
///
|
||||||
|
/// This function MUST be used for the value, whose content can not be confirmed at compile time,
|
||||||
|
/// and it will be passed to get/set value, or create/delete key functions.
|
||||||
pub fn blank_path_guard<P: AsRef<OsStr>>(path: P) -> std::result::Result<P, BlankPathError> {
|
pub fn blank_path_guard<P: AsRef<OsStr>>(path: P) -> std::result::Result<P, BlankPathError> {
|
||||||
if path.as_ref().is_empty() {
|
if path.as_ref().is_empty() {
|
||||||
Err(BlankPathError::new())
|
Err(BlankPathError::new())
|
||||||
|
|||||||
Reference in New Issue
Block a user