File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1563,10 +1563,13 @@ def join(dir, base)
15631563 else
15641564 DIRECTORY_TERM = "(?=/|\\ z)"
15651565 end
1566- SYSCASE = File ::FNM_SYSCASE . nonzero? ? "-i" : ""
15671566
15681567 def descendant_directory? ( descendant , ascendant )
1569- /\A (?#{ SYSCASE } :#{ Regexp . quote ( ascendant ) } )#{ DIRECTORY_TERM } / =~ File . dirname ( descendant )
1568+ if File ::FNM_SYSCASE . nonzero?
1569+ File . expand_path ( File . dirname ( descendant ) ) . casecmp ( File . expand_path ( ascendant ) ) == 0
1570+ else
1571+ File . expand_path ( File . dirname ( descendant ) ) == File . expand_path ( ascendant )
1572+ end
15701573 end
15711574 end # class Entry_
15721575
Original file line number Diff line number Diff line change @@ -381,6 +381,16 @@ def test_cp_r
381381 assert_same_file 'tmp/cpr_src/b' , 'tmp/cpr_dest/b'
382382 assert_same_file 'tmp/cpr_src/c' , 'tmp/cpr_dest/c'
383383 assert_directory 'tmp/cpr_dest/d'
384+ assert_raise ( ArgumentError ) do
385+ cp_r 'tmp/cpr_src' , './tmp/cpr_src'
386+ end
387+ assert_raise ( ArgumentError ) do
388+ cp_r './tmp/cpr_src' , 'tmp/cpr_src'
389+ end
390+ assert_raise ( ArgumentError ) do
391+ cp_r './tmp/cpr_src' , File . expand_path ( 'tmp/cpr_src' )
392+ end
393+
384394 my_rm_rf 'tmp/cpr_src'
385395 my_rm_rf 'tmp/cpr_dest'
386396
You can’t perform that action at this time.
0 commit comments