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_prepender << path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)).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 496 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 472 def file_search_handle(path, &block) begin # Workaround for CHEF-4419: # Make sure paths starting with "/" has a drive letter # assigned from the current working diretory. # Note: With CHEF-4427 this issue will be fixed with a # broader fix to map all the paths starting with "/" to # SYSTEM_DRIVE on windows. path = ::File.expand_path(path) if path.start_with? "/" 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 465 def path_prepender "\\\\?\\" end
# File lib/chef/win32/api/file.rb, line 526 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 511 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.