From d281f2a236a91c98dbe0399a18bc9557c1620df2 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Oct 2001 20:42:13 +0000 Subject: [PATCH] re PR libgcj/4481 (java.io.File.getParent not working properly) Fix for PR libgcj/4481: * java/io/File.java (getParent): Handle case where path is "/". (normalizePath): Use correct string for UNC leader. From-SVN: r46093 --- libjava/ChangeLog | 6 ++++++ libjava/java/io/File.java | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index b79cb493608..af67c16b8a4 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2001-10-08 Tom Tromey + + Fix for PR libgcj/4481: + * java/io/File.java (getParent): Handle case where path is "/". + (normalizePath): Use correct string for UNC leader. + 2001-10-06 Mark Wielaard * java/io/BufferedInputStream.java: Merge with Classpath diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java index 858f2b37cae..a268278fd3e 100644 --- a/libjava/java/io/File.java +++ b/libjava/java/io/File.java @@ -84,9 +84,9 @@ public class File implements Serializable, Comparable { int dupIndex = p.indexOf(dupSeparator); int plen = p.length(); - + // Special case: permit Windows UNC path prefix. - if (dupSeparator.equals("\\") && dupIndex == 0) + if (dupSeparator.equals("\\\\") && dupIndex == 0) dupIndex = p.indexOf(dupSeparator, 1); if (dupIndex == -1) @@ -181,6 +181,9 @@ public class File implements Serializable, Comparable int last = path.lastIndexOf(separatorChar); if (last == -1) return null; + // FIXME: POSIX assumption. + if (last == 0 && path.charAt (0) == '/') + ++last; return path.substring(0, last); }