summaryrefslogtreecommitdiff
path: root/lib/chef/win32
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-08-26 14:09:05 -0700
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-08-27 11:54:47 -0400
commit652b582c1ca7ceabe57cdf6b170fe97f4d661584 (patch)
tree919c0dd88cefaaa0c2c5699d267eb185761400eb /lib/chef/win32
parent3fff2b493fe51398cc139f4c4239beee193b0097 (diff)
downloadchef-652b582c1ca7ceabe57cdf6b170fe97f4d661584.tar.gz
Rewrite DeleteVolumeMountPoint to use FFI
Diffstat (limited to 'lib/chef/win32')
-rw-r--r--lib/chef/win32/api/file.rb6
-rw-r--r--lib/chef/win32/file.rb10
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index 86b2b942c2..4ea07ad39b 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -450,6 +450,12 @@ BOOL WINAPI DeviceIoControl(
=end
safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
+
+#BOOL WINAPI DeleteVolumeMountPoint(
+ #_In_ LPCTSTR lpszVolumeMountPoint
+#);
+ safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL
+
###############################################
# Helpers
###############################################
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index e6640caa3c..a577f04acc 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -20,6 +20,7 @@
require 'chef/win32/api/file'
require 'chef/win32/api/security'
require 'chef/win32/error'
+require 'chef/mixin/wstring'
class Chef
module ReservedNames::Win32
@@ -27,6 +28,9 @@ class Chef
include Chef::ReservedNames::Win32::API::File
extend Chef::ReservedNames::Win32::API::File
+ include Chef::Mixin::WideString
+ extend Chef::Mixin::WideString
+
# Creates a symbolic link called +new_name+ for the file or directory
# +old_name+.
#
@@ -176,6 +180,12 @@ class Chef
desired_access, mapping)
end
+ def self.delete_volume_mount_point(mount_point)
+ unless DeleteVolumeMountPointW(wstring(mount_point))
+ Chef::ReservedNames::Win32::Error.raise!
+ end
+ end
+
# ::File compat
class << self
alias :stat :info