summaryrefslogtreecommitdiff
path: root/lib/chef/win32/registry.rb
diff options
context:
space:
mode:
authorPrajaktaPurohit <prajakta@opscode.com>2012-11-20 14:38:05 -0800
committerLamont Granquist <lamont@opscode.com>2012-12-19 15:54:40 -0800
commita2a19ee3a85d5a266f2a2b91072612bfaa5b2dd8 (patch)
treeef87a866ff409bc48a6b044465fc439b5005e912 /lib/chef/win32/registry.rb
parent473a466f567d6fafe321c8aaa26fd1bfc6fd083a (diff)
downloadchef-a2a19ee3a85d5a266f2a2b91072612bfaa5b2dd8.tar.gz
Creating the registry provider action_create method
Diffstat (limited to 'lib/chef/win32/registry.rb')
-rw-r--r--lib/chef/win32/registry.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index da79c88380..b13fa44b93 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -253,6 +253,24 @@ class Chef
end
end
+ def data_exists?(key_path, value)
+ value_exists!(key_path, value)
+ hive, key = get_hive_and_key(key_path)
+ hive.open(key) do |reg|
+ reg.each do |val_name, val_type, val_data|
+ if val_name == value[:name]
+ type_new = get_type_from_name(value[:type])
+ if val_type == type_new
+ if val_data = value[:data]
+ return true
+ end
+ end
+ end
+ end
+ end
+ return false
+ end
+
def type_matches?(key_path, value)
value_exists!(key_path, value)
hive, key = get_hive_and_key(key_path)
@@ -275,9 +293,22 @@ class Chef
end
end
+ def get_type_from_num(val_type)
+ value = {
+ 3 => ::Win32::Registry::REG_BINARY,
+ 1 => ::Win32::Registry::REG_SZ,
+ 7 => ::Win32::Registry::REG_MULTI_SZ,
+ 2 => ::Win32::Registry::REG_EXPAND_SZ,
+ 4 => ::Win32::Registry::REG_DWORD,
+ 5 => ::Win32::Registry::REG_DWORD_BIG_ENDIAN,
+ 11 => ::Win32::Registry::REG_QWORD
+ }[val_type]
+ return value
+ end
+
def get_type_from_name(val_type)
value = {
- :binary => ::Win32::Registry::REG_BINARY,
+ :binary || 1 => ::Win32::Registry::REG_BINARY,
:string => ::Win32::Registry::REG_SZ,
:multi_string => ::Win32::Registry::REG_MULTI_SZ,
:expand_string => ::Win32::Registry::REG_EXPAND_SZ,