aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 01:24:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 01:24:46 +0000
commit7d2edb376d8d34630b3a1902f0919a1e56463e2d (patch)
tree4e6acb765a8b3968d4bc2a9d25bf6129def495ec /lib
parent7425bcc46f718ff155e0323244d6a032d5bb6819 (diff)
downloadruby-7d2edb376d8d34630b3a1902f0919a1e56463e2d.tar.gz
Refactor
* lib/fileutils.rb (FileUtils::Entry_#copy_metadata): eliminate common statements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/fileutils.rb23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index de8474f2d0..a7fca26dbb 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1273,6 +1273,7 @@ module FileUtils
if !st.symlink?
File.utime st.atime, st.mtime, path
end
+ mode = st.mode
begin
if st.symlink?
begin
@@ -1284,23 +1285,15 @@ module FileUtils
end
rescue Errno::EPERM
# clear setuid/setgid
- if st.symlink?
- begin
- File.lchmod st.mode & 01777, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode & 01777, path
+ mode &= 01777
+ end
+ if st.symlink?
+ begin
+ File.lchmod mode, path
+ rescue NotImplementedError
end
else
- if st.symlink?
- begin
- File.lchmod st.mode, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode, path
- end
+ File.chmod mode, path
end
end