diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-27 14:02:54 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-28 17:19:34 -0700 |
commit | 306423bac260655a9d4b4b152782401f03325519 (patch) | |
tree | 0b60a527c8e6a155539b7abd0912ae6b1498514b /lib/chef/util | |
parent | a9524b0e799c13e90aef846e96c8d32909b5ee39 (diff) | |
download | chef-306423bac260655a9d4b4b152782401f03325519.tar.gz |
Use FFI for NetUseDel
Diffstat (limited to 'lib/chef/util')
-rw-r--r-- | lib/chef/util/windows/net_use.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/chef/util/windows/net_use.rb b/lib/chef/util/windows/net_use.rb index 62d7e169dc..34835b6d3d 100644 --- a/lib/chef/util/windows/net_use.rb +++ b/lib/chef/util/windows/net_use.rb @@ -21,6 +21,7 @@ #see also cmd.exe: net use /? require 'chef/util/windows' +require 'chef/win32/net' class Chef::Util::Windows::NetUse < Chef::Util::Windows @@ -76,6 +77,7 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows def initialize(localname) @localname = localname @name = multi_to_wide(localname) + @use_name = localname end def add(args) @@ -111,11 +113,16 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows def device get_info()[:remote] end - #XXX should we use some FORCE here? + def delete - rc = NetUseDel.call(nil, @name, USE_NOFORCE) - if rc != NERR_Success - raise ArgumentError, get_last_error(rc) + begin + Chef::ReservedNames::Win32::Net.net_use_del(nil, use_name, :use_noforce) + rescue Chef::Exceptions::Win32APIError => e + raise ArgumentError, e end end + + def use_name + @use_name + end end |