summaryrefslogtreecommitdiff
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
authorJustin Collins <justin@presidentbeef.com>2016-09-11 02:09:43 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-06 09:01:04 +0900
commit4f1a00a746b8c47dd32f06b249aad8c4d27cb934 (patch)
tree56aa77ce552f4f001410423a76bffdad075781fa /lib/fileutils.rb
parent96cec6b27741cbdeb51ea3acdeba0e813d51035f (diff)
Improve same directory detection in FileUtils
Closes: https://github.com/ruby/ruby/pull/1425
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r--lib/fileutils.rb7
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_