Sha256: f22db251d31baaa2bfbf62bda49cbdc5a731f183e800b90bef6eae417a70cef4
Contents?: true
Size: 780 Bytes
Versions: 12
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true # Check if a file is readable. Puppet::Functions.create_function(:'file::readable', Puppet::Functions::InternalFunction) do # @param filename Absolute path or Puppet file path. # @return Whether the file is readable. # @example Check a file on disk # file::readable('/tmp/i_dumped_this_here') # @example check a file from the modulepath # file::readable('example/files/VERSION') dispatch :readable do scope_param required_param 'String', :filename return_type 'Boolean' end def readable(scope, filename) Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name) found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment) found ? File.readable?(found) : false end end
Version data entries
12 entries across 12 versions & 1 rubygems