diff options
author | Justin Collins <justin@presidentbeef.com> | 2016-09-11 02:09:43 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-08-06 09:01:04 +0900 |
commit | 4f1a00a746b8c47dd32f06b249aad8c4d27cb934 (patch) | |
tree | 56aa77ce552f4f001410423a76bffdad075781fa /lib | |
parent | 96cec6b27741cbdeb51ea3acdeba0e813d51035f (diff) | |
download | ruby-4f1a00a746b8c47dd32f06b249aad8c4d27cb934.tar.gz |
Improve same directory detection in FileUtils
Closes: https://github.com/ruby/ruby/pull/1425
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileutils.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index ff667fb1b0..cfc6ef1ec8 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1546,10 +1546,13 @@ module FileUtils else DIRECTORY_TERM = "(?=/|\\z)" end - SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : "" def descendant_directory?(descendant, ascendant) - /\A(?#{SYSCASE}:#{Regexp.quote(ascendant)})#{DIRECTORY_TERM}/ =~ File.dirname(descendant) + if File::FNM_SYSCASE.nonzero? + File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0 + else + File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant) + end end end # class Entry_ |