summaryrefslogtreecommitdiff
path: root/lib/chef/provider/env/windows.rb
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-09-09 17:44:36 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-11 12:12:55 -0700
commit3f01d0a3ad058e3b21244d205ac1a7ad793875dc (patch)
treec0304f06d6c15f461c18a6ac411abdfc2275f37b /lib/chef/provider/env/windows.rb
parente6613a101de325caab78a1b392d0a149d02e270c (diff)
downloadchef-3f01d0a3ad058e3b21244d205ac1a7ad793875dc.tar.gz
Use windows api to expand path. Cleaned up tests
Diffstat (limited to 'lib/chef/provider/env/windows.rb')
-rw-r--r--lib/chef/provider/env/windows.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/provider/env/windows.rb b/lib/chef/provider/env/windows.rb
index 990ab178af..79abda8708 100644
--- a/lib/chef/provider/env/windows.rb
+++ b/lib/chef/provider/env/windows.rb
@@ -33,10 +33,9 @@ class Chef
end
obj.variablevalue = @new_resource.value
obj.put_
- value = @new_resource.value
+ value = @new_resource.value
value = expand_path(value) if @new_resource.key_name.upcase == 'PATH'
ENV[@new_resource.key_name] = value
-
broadcast_env_change
end
@@ -78,10 +77,11 @@ class Chef
private
def expand_path(path)
- system_vars = %w(HomeDrive HomePath ProgramFiles SystemDirectory SystemDrive SystemRoot Temp Tmp UserProfile WinDir)
- system_vars.each_with_object(path) do |variable, new_path|
- new_path.gsub!(/%#{variable}%/i, ENV[variable]) if ENV[variable]
+ buf = 0.chr * 32 * (1 << 10) # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724265%28v=vs.85%29.aspx
+ if ExpandEnvironmentStringsA(path, buf, buf.length) == 0
+ Chef::ReservedNames::Win32::Error.raise!
end
+ buf.strip
end
end
end