diff options
Diffstat (limited to 'lib/chef/win32')
-rw-r--r-- | lib/chef/win32/api/file.rb | 7 | ||||
-rw-r--r-- | lib/chef/win32/file.rb | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index c48e992882..728a6c14df 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -462,6 +462,13 @@ BOOL WINAPI DeviceIoControl( #); safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL +#BOOL WINAPI GetVolumeNameForVolumeMountPoint( + #_In_ LPCTSTR lpszVolumeMountPoint, + #_Out_ LPTSTR lpszVolumeName, + #_In_ DWORD cchBufferLength +#); + safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL + ############################################### # Helpers ############################################### diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb index f62f9333f5..57347643fc 100644 --- a/lib/chef/win32/file.rb +++ b/lib/chef/win32/file.rb @@ -192,6 +192,13 @@ class Chef end end + def self.get_volume_name_for_volume_mount_point(mount_point) + buffer = FFI::MemoryPointer.new(2, 128) + unless GetVolumeNameForVolumeMountPointW(wstring(mount_point), buffer, buffer.size/buffer.type_size) + Chef::ReservedNames::Win32::Error.raise! + end + buffer.read_wstring + end # ::File compat class << self |