diff options
author | Seth Chisamore <schisamo@opscode.com> | 2011-09-12 20:38:06 -0400 |
---|---|---|
committer | Seth Chisamore <schisamo@opscode.com> | 2011-09-12 20:38:06 -0400 |
commit | c2491788a77fc310d5e600acb3e0b5f3fd7b4960 (patch) | |
tree | 0b8e2451a1b92960ed38403a7ef58767917a7a87 /libraries | |
parent | 75a9e74370aa803abc1b9bb6e3d0aca474394724 (diff) | |
download | mixlib-shellout-c2491788a77fc310d5e600acb3e0b5f3fd7b4960.tar.gz |
new get_values method which returns all values for a particular key
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/registry_helper.rb | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/libraries/registry_helper.rb b/libraries/registry_helper.rb index 2c6e328..a385783 100644 --- a/libraries/registry_helper.rb +++ b/libraries/registry_helper.rb @@ -106,10 +106,7 @@ module Windows Chef::Log.debug("setting #{key}=#{val}")
reg[key] = val
- if(hive_loaded)
- Chef::Log.debug("Hive was loaded, we really should unload it")
- unload_hive(path)
- end
+ ensure_hive_unloaded(hive_loaded)
return true
end
@@ -128,14 +125,26 @@ module Windows rescue
return nil
ensure
- if(hive_loaded)
- Chef::Log.debug("Hive was loaded, we really should unload it")
- unload_hive(path)
- end
+ ensure_hive_unloaded(hive_loaded)
end
end
+ end
-
+ def get_values(path)
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
+ key = reg_path.join("\\")
+ hive.open(key, Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do | reg |
+ values = []
+ begin
+ reg.each_value do |name, type, data|
+ values << [name, type, data]
+ end
+ rescue
+ ensure
+ ensure_hive_unloaded(hive_loaded)
+ end
+ values
+ end
end
def delete_value(path,values)
@@ -176,10 +185,7 @@ module Windows rescue
return false
ensure
- if(hive_loaded)
- Chef::Log.debug("Hive was loaded, we really should unload it")
- unload_hive(path)
- end
+ ensure_hive_unloaded(hive_loaded)
end
end
@@ -207,10 +213,7 @@ module Windows rescue
return false
ensure
- if(hive_loaded)
- Chef::Log.debug("Hive was loaded, we really should unload it")
- unload_hive(path)
- end
+ ensure_hive_unloaded(hive_loaded)
end
end
@@ -315,9 +318,18 @@ module Windows return reg_path, load_reg
end
+
+ private
+ def ensure_hive_unloaded(hive_loaded=false)
+ if(hive_loaded)
+ Chef::Log.debug("Hive was loaded, we really should unload it")
+ unload_hive(path)
+ end
+ end
end
end
-class Registry
+module Registry
+ module_function
extend Windows::RegistryHelper
end
\ No newline at end of file |