summaryrefslogtreecommitdiffstats
path: root/libjava/java/io/File.java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-02 00:36:03 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-02 00:36:03 +0000
commit2b72a6c3ce7672bc484d34ccaa89bc893bc03840 (patch)
tree01d9125b79e1f1a6ddae6430cffd78841636a6e2 /libjava/java/io/File.java
parentb8ba347e9bd9322f023adeddda679735d863cff8 (diff)
downloadppe42-gcc-2b72a6c3ce7672bc484d34ccaa89bc893bc03840.tar.gz
ppe42-gcc-2b72a6c3ce7672bc484d34ccaa89bc893bc03840.zip
2003-03-01 Ranjit Mathew <rmathew@hotmail.com>
* 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
Diffstat (limited to 'libjava/java/io/File.java')
-rw-r--r--libjava/java/io/File.java22
1 files changed, 16 insertions, 6 deletions
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));
OpenPOWER on IntegriCloud