fileutils_cp_permissions.patch

Oleg Shaldybin, 03/18/2011 06:57 AM

Download (1.48 KB)

View differences:

ChangeLog (working copy)
1
Fri Mar 18 06:22:27 2011  Oleg Shaldybin  <oleg.shaldybin@gmail.com>
2

  
3
	* lib/fileutils.rb (FileUtils::Entry_#copy_file): updated FileUtils.cp
4
	  to still copy file permissions when :preserve is false (as cp does
5
	  this even when -p isn't set).
6

  
1 7
Fri Mar 18 00:59:38 2011  Nobuyoshi Nakada  <nobu@ruby-lang.org>
2 8

  
3 9
	* ext/win32ole/extconf.rb (create_docfile): removed.  should not
lib/fileutils.rb (working copy)
1275 1275
    end
1276 1276

  
1277 1277
    def copy_file(dest)
1278
      st = stat()
1278 1279
      File.open(path()) do |s|
1279
        File.open(dest, 'wb') do |f|
1280
        File.open(dest, 'wb', st.mode) do |f|
1280 1281
          IO.copy_stream(s, f)
1281 1282
        end
1282 1283
      end
test/fileutils/test_fileutils.rb (working copy)
230 230
    }
231 231
  end
232 232

  
233
  def test_cp_preserve_permissions
234
    touch 'tmp/cptmp'
235
    chmod 0755, 'tmp/cptmp'
236
    cp 'tmp/cptmp', 'tmp/cptmp2'
237
    assert_equal File.stat('tmp/cptmp').mode, File.stat('tmp/cptmp2').mode
238
  end
239

  
233 240
  def test_cp_symlink
234 241
    touch 'tmp/cptmp'
235 242
    # src==dest (2) symlink and its target