Access
DeviceIoControl control codes
TODO add the rest of these CONSTS
Reparse point tags
Methods
takes the given path pre-pends "\?" and UTF-16LE encodes it. Used to prepare paths to be passed to the *W vesion of WinAPI File functions
# File lib/chef/win32/api/file.rb, line 461 def encode_path(path) path.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) (path_prepender << path).to_wstring end
retrieves a file handle and passes it to +&block+ along with the find_data. also ensures the handle is closed on exit of the block
# File lib/chef/win32/api/file.rb, line 490 def file_handle(path, &block) begin path = encode_path(path) handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, nil) if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end block.call(handle) ensure CloseHandle(handle) if handle && handle != INVALID_HANDLE_VALUE end end
retrieves a file search handle and passes it to +&block+ along with the find_data. also ensures the handle is closed on exit of the block
# File lib/chef/win32/api/file.rb, line 473 def file_search_handle(path, &block) begin path = encode_path(path) find_data = WIN32_FIND_DATA.new handle = FindFirstFileW(path, find_data) if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end block.call(handle, find_data) ensure FindClose(handle) if handle && handle != INVALID_HANDLE_VALUE end end
# File lib/chef/win32/api/file.rb, line 466 def path_prepender "\\\\?\\" end
# File lib/chef/win32/api/file.rb, line 520 def retrieve_file_info(file_name) file_information = nil file_handle(file_name) do |handle| file_information = BY_HANDLE_FILE_INFORMATION.new success = GetFileInformationByHandle(handle, file_information) if success == 0 Chef::ReservedNames::Win32::Error.raise! end end file_information end
# File lib/chef/win32/api/file.rb, line 505 def symlink_file_handle(path, &block) begin path = encode_path(path) handle = CreateFileW(path, FILE_READ_EA, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nil) if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end block.call(handle) ensure CloseHandle(handle) if handle && handle != INVALID_HANDLE_VALUE end end
Generated with the Darkfish Rdoc Generator 2.