class Inspec::Resources::FileResource

def contain(*_)

def contain(*_)
  fail 'Contain is not supported. Please use standard RSpec matchers.'
end

def content

def content
  res = file.content
  return nil if res.nil?
  res.force_encoding('utf-8')
end

def executable?(by_usergroup, by_specific_user)

def executable?(by_usergroup, by_specific_user)
  return false unless exist?
  return skip_resource '`executable?` is not supported on your OS yet.' if @perms_provider.nil?
  file_permission_granted?('execute', by_usergroup, by_specific_user)
end

def file_permission_granted?(access_type, by_usergroup, by_specific_user)

def file_permission_granted?(access_type, by_usergroup, by_specific_user)
  fail '`file_permission_granted?` is not supported on your OS' if @perms_provider.nil?
  if by_specific_user.nil? || by_specific_user.empty?
    @perms_provider.check_file_permission_by_mask(file, access_type, by_usergroup, by_specific_user)
  else
    @perms_provider.check_file_permission_by_user(access_type, by_specific_user, source_path)
  end
end

def initialize(path)

def initialize(path)
  # select permissions style
  @perms_provider = select_file_perms_style(inspec.os)
  @file = inspec.backend.file(path)
end

def mounted?(expected_options = nil, identical = false)

def mounted?(expected_options = nil, identical = false)
  mounted = file.mounted
  # return if no additional parameters have been provided
  return file.mounted? if expected_options.nil?
  # deprecation warning, this functionality will be removed in future version
  warn "[DEPRECATION] `be_mounted.with and be_mounted.only_with` are deprecated.  Please use `mount('#{source_path}')` instead."
  # we cannot read mount data on non-Linux systems
  return nil if !inspec.os.linux?
  # parse content if we are on linux
  @mount_options ||= parse_mount_options(mounted.stdout, true)
  if identical
    # check if the options should be identical
    @mount_options == expected_options
  else
    # otherwise compare the selected values
    @mount_options.contains(expected_options)
  end
end

def readable?(by_usergroup, by_specific_user)

def readable?(by_usergroup, by_specific_user)
  return false unless exist?
  return skip_resource '`readable?` is not supported on your OS yet.' if @perms_provider.nil?
  file_permission_granted?('read', by_usergroup, by_specific_user)
end

def sgid

def sgid
  (mode & 02000) > 0
end

def sticky

def sticky
  (mode & 01000) > 0
end

def suid

def suid
  (mode & 04000) > 0
end

def to_s

def to_s
  "File #{source_path}"
end

def writable?(by_usergroup, by_specific_user)

def writable?(by_usergroup, by_specific_user)
  return false unless exist?
  return skip_resource '`writable?` is not supported on your OS yet.' if @perms_provider.nil?
  file_permission_granted?('write', by_usergroup, by_specific_user)
end