summaryrefslogtreecommitdiff
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 07:58:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 07:58:34 +0000
commit2a5183c2e44f87a8901bdcbf7e5891f9ba07e8fc (patch)
treecf32eef678709e05325d41f3ef4515d56c5b0528 /lib/fileutils.rb
parent10fcca8f153e7d5265bed2a8b42e945f2be7819b (diff)
FileUtils#install: symbolic mode
* lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as well as chmod. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r--lib/fileutils.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index d5bda95b58..e9e9019a58 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -759,7 +759,7 @@ module FileUtils
if verbose
msg = +"install -c"
msg << ' -p' if preserve
- msg << ' -m 0%o' % mode if mode
+ msg << ' -m ' << mode_to_s(mode) if mode
msg << " -o #{owner}" if owner
msg << " -g #{group}" if group
msg << ' ' << [src,dest].flatten.join(' ')
@@ -774,7 +774,7 @@ module FileUtils
remove_file d, true
copy_file s, d
File.utime st.atime, st.mtime, d if preserve
- File.chmod mode, d if mode
+ File.chmod fu_mode(mode, st), d if mode
File.chown uid, gid, d if uid or gid
end
end
@@ -812,7 +812,12 @@ module FileUtils
private_module_function :apply_mask
def symbolic_modes_to_i(mode_sym, path) #:nodoc:
- mode_sym.split(/,/).inject(File.stat(path).mode & 07777) do |current_mode, clause|
+ mode = if File::Stat === path
+ path.mode
+ else
+ File.stat(path).mode
+ end
+ mode_sym.split(/,/).inject(mode & 07777) do |current_mode, clause|
target, *actions = clause.split(/([=+-])/)
raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty?
target = 'a' if target.empty?