1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

win32/registry.rb: registry type names

* ext/win32/lib/win32/registry.rb (Win32::Registry#read): show
  registry type names instead of numeric values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-01-04 11:06:16 +00:00
parent 3047144ac2
commit 70db4f6ecd

View file

@ -643,7 +643,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
def read(name, *rtype) def read(name, *rtype)
type, data = API.QueryValue(@hkey, name) type, data = API.QueryValue(@hkey, name)
unless rtype.empty? or rtype.include?(type) unless rtype.empty? or rtype.include?(type)
raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)" raise TypeError, "Type mismatch (expect [#{
rtype.map{|t|Registry.type2name(t)}.join(', ')}] but #{
Registry.type2name(type)} present)"
end end
case type case type
when REG_SZ, REG_EXPAND_SZ when REG_SZ, REG_EXPAND_SZ
@ -659,7 +661,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
when REG_QWORD when REG_QWORD
[ type, API.unpackqw(data) ] [ type, API.unpackqw(data) ]
else else
raise TypeError, "Type #{type} is not supported." raise TypeError, "Type #{Registry.type2name(type)} is not supported."
end end
end end
@ -682,7 +684,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
when REG_EXPAND_SZ when REG_EXPAND_SZ
Registry.expand_environ(data) Registry.expand_environ(data)
else else
raise TypeError, "Type #{type} is not supported." raise TypeError, "Type #{Registry.type2name(type)} is not supported."
end end
end end
@ -755,7 +757,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
when REG_QWORD when REG_QWORD
data = API.packqw(data.to_i) data = API.packqw(data.to_i)
else else
raise TypeError, "Unsupported type #{type}" raise TypeError, "Unsupported type #{Registry.type2name(type)}"
end end
API.SetValue(@hkey, name, type, data, data.bytesize + termsize) API.SetValue(@hkey, name, type, data, data.bytesize + termsize)
end end