Method: FileUtils2#chown
- Defined in:
- lib/fileutils2.rb
#chown(user, group, list, options = {}) ⇒ Object
Options: noop verbose
Changes owner and group on the named files (in list) to the user user and the group group. user and group may be an ID (Integer/String) or a name (String). If user or group is nil, this method does not change the attribute.
FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
# File 'lib/fileutils2.rb', line 1106 def chown(user, group, list, = {}) , OPT_TABLE['chown'] list = fu_list(list) sprintf('chown %s%s', [user,group].compact.join(':') + ' ', list.join(' ')) if [:verbose] return if [:noop] uid = fu_get_uid(user) gid = fu_get_gid(group) list.each do |path| Entry_.new(path).chown uid, gid end end |