From 2b72a6c3ce7672bc484d34ccaa89bc893bc03840 Mon Sep 17 00:00:00 2001 From: tromey Date: Sun, 2 Mar 2003 00:36:03 +0000 Subject: 2003-03-01 Ranjit Mathew * java/io/File.java (normalizePath): Remove trailing separator on Windows only if path is not of the form "x:\". * java/io/natFileWin32.cc (WIN32_EPOCH_MILLIS): New constant. (java::io::File::attr): Change formatting a bit and use WIN32_EPOCH_MILLIS instead of magic numbers. (java::io::File::isAbsolute): Path must have at least 3 characters for a UNC network path. (java::io::File::init_native): Define. (java::io::File::performCreate): Likewise. (java::io::File::performSetReadOnly): Likewise. (java::io::File::performSetLastModified): Likewise. (java::io::File::performListRoots): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63646 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/io/File.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'libjava/java/io/File.java') diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java index 367fd44eb69..0f11bce669d 100644 --- a/libjava/java/io/File.java +++ b/libjava/java/io/File.java @@ -96,9 +96,13 @@ public class File implements Serializable, Comparable if (dupIndex == -1) { - // Ignore trailing separator. - if (plen > 1 && p.charAt(plen - 1) == separatorChar) - return p.substring(0, plen - 1); + // Ignore trailing separator (though on Windows "a:\", for + // example, is a valid and minimal path). + if (plen > 1 && p.charAt (plen - 1) == separatorChar) + { + if (! (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':')) + return p.substring (0, plen - 1); + } else return p; } @@ -120,10 +124,16 @@ public class File implements Serializable, Comparable dupIndex = p.indexOf(dupSeparator, last); } - // Again, ignore possible trailing separator. + // Again, ignore possible trailing separator (except special cases + // like "a:\" on Windows). int end; - if (plen > 1 && p.charAt(plen - 1) == separatorChar) - end = plen - 1; + if (plen > 1 && p.charAt (plen - 1) == separatorChar) + { + if (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':') + end = plen; + else + end = plen - 1; + } else end = plen; newpath.append(p.substring(last, end)); -- cgit v1.2.1