diff options
author | Ranjit Mathew <rmathew@hotmail.com> | 2003-03-02 00:36:03 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-03-02 00:36:03 +0000 |
commit | 3ccd3d704112889a79a0ccdcfc51bfcc55019827 (patch) | |
tree | 01d9125b79e1f1a6ddae6430cffd78841636a6e2 /libjava/java/io/File.java | |
parent | d457094cc1695409b74aa40a7d095d39dfcf943e (diff) | |
download | gcc-3ccd3d704112889a79a0ccdcfc51bfcc55019827.zip gcc-3ccd3d704112889a79a0ccdcfc51bfcc55019827.tar.gz gcc-3ccd3d704112889a79a0ccdcfc51bfcc55019827.tar.bz2 |
File.java (normalizePath): Remove trailing separator on Windows only if path is not of the form "x:\".
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.
From-SVN: r63646
Diffstat (limited to 'libjava/java/io/File.java')
-rw-r--r-- | libjava/java/io/File.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java index 367fd44..0f11bce 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)); |