diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-28 23:59:28 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-28 23:59:28 +0000 |
| commit | fdb335a3a9458f56f12e4341485aff431ab2fe96 (patch) | |
| tree | 9e65486b8a4299774861053672680761b3bb663a /lib | |
| parent | 45951eb88532c6cdb384ab8340a367f59a6b68e3 (diff) | |
| download | ruby-fdb335a3a9458f56f12e4341485aff431ab2fe96.tar.gz ruby-fdb335a3a9458f56f12e4341485aff431ab2fe96.tar.xz ruby-fdb335a3a9458f56f12e4341485aff431ab2fe96.zip | |
* lib/pathname.rb (Pathname#relative_path_from): compares path
components according to system default case-sensitiveness.
[ruby-core:22829]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pathname.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/pathname.rb b/lib/pathname.rb index 75faaef8b..7b7ed374e 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -197,6 +197,13 @@ class Pathname # to_path is implemented so Pathname objects are usable with File.open, etc. TO_PATH = :to_path end + + SAME_PATHS = if File::FNM_SYSCASE + proc {|a, b| a.casecmp(b).zero?} + else + proc {|a, b| a == b} + end + # :startdoc: # @@ -786,12 +793,12 @@ class Pathname base_prefix, basename = r base_names.unshift basename if basename != '.' end - if dest_prefix != base_prefix + unless SAME_PATHS[dest_prefix, base_prefix] raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}" end while !dest_names.empty? && !base_names.empty? && - dest_names.first == base_names.first + SAME_PATHS[dest_names.first, base_names.first] dest_names.shift base_names.shift end |
