ruby-changes:43437
From: nobu <ko1@a...>
Date: Mon, 27 Jun 2016 10:24:52 +0900 (JST)
Subject: [ruby-changes:43437] nobu:r55511 (trunk): Refactor
nobu 2016-06-27 10:24:46 +0900 (Mon, 27 Jun 2016) New Revision: 55511 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55511 Log: Refactor * lib/fileutils.rb (FileUtils::Entry_#copy_metadata): eliminate common statements. Modified files: trunk/lib/fileutils.rb Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 55510) +++ lib/fileutils.rb (revision 55511) @@ -1273,6 +1273,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1273 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 https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1285 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/