[kaffe] CVS kaffe (guilhem): Merged case insensitivity from classpath.
Kaffe CVS
Kaffe Mailing List <kaffe@kaffe.org>
Wed Dec 31 01:17:01 2003
PatchSet 4249
Date: 2003/12/31 09:14:18
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Merged case insensitivity from classpath.
Members:
ChangeLog:1.1836->1.1837
libraries/javalib/java/io/File.java:1.40->1.41
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1836 kaffe/ChangeLog:1.1837
--- kaffe/ChangeLog:1.1836 Wed Dec 31 09:09:36 2003
+++ kaffe/ChangeLog Wed Dec 31 09:14:18 2003
@@ -1,4 +1,10 @@
2003-12-31 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * libraries/javalib/java/io/File.java: Merged case insensitivity
+ from classpath.
+ (File): Fixed root directory handling on windows platform.
+
+2003-12-31 Guilhem Lavaux <guilhem@kaffe.org>
* libraries/javalib/java/net/URL.java,
libraries/javalib/java/net/URLStreamHandler.java:
Index: kaffe/libraries/javalib/java/io/File.java
diff -u kaffe/libraries/javalib/java/io/File.java:1.40 kaffe/libraries/javalib/java/io/File.java:1.41
--- kaffe/libraries/javalib/java/io/File.java:1.40 Sat Oct 25 18:30:23 2003
+++ kaffe/libraries/javalib/java/io/File.java Wed Dec 31 09:14:20 2003
@@ -94,6 +94,9 @@
* is taken from the <code>path.separator</code> system property.
*/
public static final char pathSeparatorChar = pathSeparator.charAt(0);
+
+ // FIXME: We support only caseSensitive filesystems currently.
+ static boolean caseSensitive = true;
static
{
@@ -264,15 +267,15 @@
*/
public boolean equals (Object obj)
{
- if (obj == null)
+ if (! (obj instanceof File))
return false;
- if (!(obj instanceof File))
- return false;
+ File other = (File) obj;
- File f = (File) obj;
-
- return f.getPath ().equals (getPath ());
+ if (caseSensitive)
+ return path.equals (other.path);
+ else
+ return path.equalsIgnoreCase (other.path);
}
/*
@@ -288,9 +291,9 @@
*
* @exception SecurityException If reading of the file is not permitted
*/
- public boolean exists ()
+ public boolean exists()
{
- checkRead ();
+ checkRead();
return existsInternal (path);
}
@@ -356,12 +359,15 @@
*/
public File (File directory, String name)
{
+ if (name == null)
+ throw new NullPointerException("filename is null");
+
String dirPath;
if (directory == null)
dirPath = "";
else if (directory.getPath() == "")
- dirPath = "/";
+ dirPath = PlatformHelper.isWindows ? "\\" : "/";
else
dirPath = directory.getPath();
@@ -520,9 +526,12 @@
*
* @return The hash code for this object
*/
- public int hashCode ()
+ public int hashCode()
{
- return path.hashCode() ^ 1234321;
+ if (caseSensitive)
+ return path.hashCode() ^ 1234321;
+ else
+ return path.toLowerCase().hashCode() ^ 1234321;
}
/**
@@ -1260,23 +1269,23 @@
if (time < 0)
throw new IllegalArgumentException("Negative modification time: " + time);
- checkWrite ();
+ checkWrite();
return setLastModifiedInternal (path, time);
}
- private void checkWrite ()
+ private void checkWrite()
{
// Check the SecurityManager
- SecurityManager s = System.getSecurityManager ();
+ SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkWrite (path);
}
- private void checkRead ()
+ private void checkRead()
{
// Check the SecurityManager
- SecurityManager s = System.getSecurityManager ();
+ SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkRead (path);
@@ -1323,32 +1332,32 @@
*
* @since 1.2
*/
- public void deleteOnExit ()
+ public void deleteOnExit()
{
// Check the SecurityManager
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkDelete(path);
- deleteHelper.filesToDelete.add (getAbsolutePath());
+ deleteHelper.filesToDelete.add(getAbsolutePath());
return;
}
private void writeObject (ObjectOutputStream oos) throws IOException
{
- oos.defaultWriteObject ();
+ oos.defaultWriteObject();
oos.writeChar (separatorChar);
}
private void readObject (ObjectInputStream ois)
throws ClassNotFoundException, IOException
{
- ois.defaultReadObject ();
+ ois.defaultReadObject();
// If the file was from an OS with a different dir separator,
// fixup the path to use the separator on this OS.
- char oldSeparatorChar = ois.readChar ();
+ char oldSeparatorChar = ois.readChar();
if (oldSeparatorChar != separatorChar)
path = path.replace (oldSeparatorChar, separatorChar);