class Chef::ReservedNames::Win32::File

Public Class Methods

delete_volume_mount_point(mount_point) click to toggle source
# File lib/chef/win32/file.rb, line 196
def self.delete_volume_mount_point(mount_point)
  unless DeleteVolumeMountPointW(wstring(mount_point))
    Chef::ReservedNames::Win32::Error.raise!
  end
end
file_access_check(path, desired_access) click to toggle source
# File lib/chef/win32/file.rb, line 175
def self.file_access_check(path, desired_access)
  security_descriptor = Chef::ReservedNames::Win32::Security.get_file_security(path)
  token_rights = Chef::ReservedNames::Win32::Security::TOKEN_IMPERSONATE |
    Chef::ReservedNames::Win32::Security::TOKEN_QUERY |
    Chef::ReservedNames::Win32::Security::TOKEN_DUPLICATE |
    Chef::ReservedNames::Win32::Security::STANDARD_RIGHTS_READ
  token = Chef::ReservedNames::Win32::Security.open_process_token(
    Chef::ReservedNames::Win32::Process.get_current_process,
    token_rights)
  duplicate_token = token.duplicate_token(:SecurityImpersonation)

  mapping = Chef::ReservedNames::Win32::Security::GENERIC_MAPPING.new
  mapping[:GenericRead] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ
  mapping[:GenericWrite] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_WRITE
  mapping[:GenericExecute] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_EXECUTE
  mapping[:GenericAll] = Chef::ReservedNames::Win32::Security::FILE_ALL_ACCESS

  Chef::ReservedNames::Win32::Security.access_check(security_descriptor, duplicate_token,
                                                    desired_access, mapping)
end
get_long_path_name(path) click to toggle source

Gets the long form of a path (ADMINI~1 -> Administrator)

# File lib/chef/win32/file.rb, line 146
def self.get_long_path_name(path)
  path = path.to_wstring
  size = GetLongPathNameW(path, nil, 0)
  if size == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result = FFI::MemoryPointer.new :char, (size + 1) * 2
  if GetLongPathNameW(path, result, size + 1) == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result.read_wstring(size)
end
get_short_path_name(path) click to toggle source

Gets the short form of a path (Administrator -> ADMINI~1)

# File lib/chef/win32/file.rb, line 132
def self.get_short_path_name(path)
  path = path.to_wstring
  size = GetShortPathNameW(path, nil, 0)
  if size == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result = FFI::MemoryPointer.new :char, (size + 1) * 2
  if GetShortPathNameW(path, result, size + 1) == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result.read_wstring(size)
end
get_volume_name_for_volume_mount_point(mount_point) click to toggle source
# File lib/chef/win32/file.rb, line 208
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
info(file_name) click to toggle source
# File lib/chef/win32/file.rb, line 159
def self.info(file_name)
  Info.new(file_name)
end
Also aliased as: stat
realpath(file_name) click to toggle source
# File lib/chef/win32/file.rb, line 92
def self.realpath(file_name)
  if symlink?(file_name)
    readlink(file_name)
  else
    file_name
  end
end
set_volume_mount_point(mount_point, name) click to toggle source
# File lib/chef/win32/file.rb, line 202
def self.set_volume_mount_point(mount_point, name)
  unless SetVolumeMountPointW(wstring(mount_point), wstring(name))
    Chef::ReservedNames::Win32::Error.raise!
  end
end
stat(file_name)
Alias for: info
version_info(file_name) click to toggle source
# File lib/chef/win32/file.rb, line 163
def self.version_info(file_name)
  VersionInfo.new(file_name)
end