diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-26 14:22:18 -0700 |
---|---|---|
committer | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-08-27 11:54:50 -0400 |
commit | 5a863dc4331799b5876edcf5fdc31666f47888d6 (patch) | |
tree | c4cb5054c7869735b64bf35859d14684703c8eba | |
parent | 652b582c1ca7ceabe57cdf6b170fe97f4d661584 (diff) | |
download | chef-5a863dc4331799b5876edcf5fdc31666f47888d6.tar.gz |
Convert SetVolumeMountPoint to use ffi
-rw-r--r-- | lib/chef/util/windows/volume.rb | 6 | ||||
-rw-r--r-- | lib/chef/win32/api/file.rb | 6 | ||||
-rw-r--r-- | lib/chef/win32/file.rb | 7 |
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/chef/util/windows/volume.rb b/lib/chef/util/windows/volume.rb index 15780d61a1..e28a5091ac 100644 --- a/lib/chef/util/windows/volume.rb +++ b/lib/chef/util/windows/volume.rb @@ -52,8 +52,10 @@ class Chef::Util::Windows::Volume < Chef::Util::Windows end def add(args) - unless SetVolumeMountPoint(@name, args[:remote]) - raise ArgumentError, get_last_error + begin + Chef::ReservedNames::Win32::File.set_volume_mount_point(@name, args[:remote]) + rescue Chef::Exceptions::Win32APIError => e + raise ArgumentError, e end end end diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index 4ea07ad39b..c48e992882 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -456,6 +456,12 @@ BOOL WINAPI DeviceIoControl( #); safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL +#BOOL WINAPI SetVolumeMountPoint( + #_In_ LPCTSTR lpszVolumeMountPoint, + #_In_ LPCTSTR lpszVolumeName +#); + safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL + ############################################### # Helpers ############################################### diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb index a577f04acc..f62f9333f5 100644 --- a/lib/chef/win32/file.rb +++ b/lib/chef/win32/file.rb @@ -186,6 +186,13 @@ class Chef end end + def self.set_volume_mount_point(mount_point, name) + unless SetVolumeMountPointW(wstring(mount_point), wstring(name)) + Chef::ReservedNames::Win32::Error.raise! + end + end + + # ::File compat class << self alias :stat :info |