Method: FileUtils.chmod_R

Defined in:
lib/extensions/fileutils/fileutils.rb

.chmod_R(mode, list, options = {}) ⇒ Object

Options: noop verbose force

Changes permission bits on the named files (in list) to the bit pattern represented by mode.

FileUtils.chmod_R 0700, "/tmp/app.#{$$}"


894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
# File 'lib/extensions/fileutils/fileutils.rb', line 894

def chmod_R(mode, list, options = {})
  fu_check_options options, OPT_TABLE['chmod_R']
  list = fu_list(list)
  fu_output_message sprintf('chmod -R%s %o %s',
                            (options[:force] ? 'f' : ''),
                            mode, list.join(' ')) if options[:verbose]
  return if options[:noop]
  list.each do |root|
    Entry_.new(root).traverse do |ent|
      begin
        ent.chmod mode
      rescue
        raise unless options[:force]
      end
    end
  end
end