Hi,
I found File.dirname got the different results when run it on jruby-1.0.3and on
ruby-1.8.5.
jruby -e 'p File.dirname("C://a")'
C:/
ruby -e 'p File.dirname("C://a")'
C:
also:
jruby -e 'p File.dirname("//a/b")'
//a
ruby -e 'p File.dirname("//a/b")'
/a
I try to give the solution for the first problem, FYI. Do you have the
better way?
diff -u org/jruby/RubyFile.java org/jruby/RubyFile.java.new
--- org/jruby/RubyFile.java 2008-01-21 15:40:14.000000000 +0800
+++ org/jruby/RubyFile.java.new 2008-01-21 15:41:00.000000000 +0800
@@ -647,6 +647,14 @@
} else {
//TODO deal with UNC names
int index = name.lastIndexOf('/');
+ while (index > 0) {
+ if (name.charAt(index-1) == '/') {
+ index --;
+ }
+ else {
+ break;
+ }
+ }
if (index == -1) return recv.getRuntime().newString(".");
if (index == 0) return recv.getRuntime().newString("/");