This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: java.io.FileDescriptor and java.io.FileInputStream
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 15:45:00 +0200
- Subject: Patch: java.io.FileDescriptor and java.io.FileInputStream
Hi list,
I just commited the attached patch to merge two fixes from classpath
java.io.
Michael
2004-04-20 Jeroen Frijters <jeroen@frijters.net>
* java/io/FileDescriptor.java: (FileDescriptor) Added public
constructor. (valid) Added null check.
2004-04-20 Guilhem Lavaux <guilhem@kaffe.org>
Reported by Nektarios Papadopoulos
<npapadop@inaccessnetworks.com>
* java/io/FileOutputStream.java
(FileOutputStream) Reorganized constructors. Constructors now
check whether the given path is directory.
Index: java/io/FileDescriptor.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileDescriptor.java,v
retrieving revision 1.18
diff -u -r1.18 FileDescriptor.java
--- java/io/FileDescriptor.java 29 Feb 2004 19:12:15 -0000 1.18
+++ java/io/FileDescriptor.java 20 Apr 2004 13:43:04 -0000
@@ -83,6 +83,14 @@
/**
* This method is used to initialize an invalid FileDescriptor object.
*/
+ public FileDescriptor()
+ {
+ channel = null;
+ }
+
+ /**
+ * This method is used to initialize a FileDescriptor object.
+ */
FileDescriptor(ByteChannel channel)
{
this.channel = channel;
@@ -125,6 +133,6 @@
*/
public boolean valid ()
{
- return channel.isOpen();
+ return channel != null && channel.isOpen();
}
}
Index: java/io/FileOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileOutputStream.java,v
retrieving revision 1.16
diff -u -r1.16 FileOutputStream.java
--- java/io/FileOutputStream.java 29 Feb 2004 19:12:15 -0000 1.16
+++ java/io/FileOutputStream.java 20 Apr 2004 13:43:04 -0000
@@ -81,13 +81,7 @@
public FileOutputStream (String path, boolean append)
throws SecurityException, FileNotFoundException
{
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkWrite(path);
- ch = new FileChannelImpl (path, (append
- ? FileChannelImpl.WRITE
- | FileChannelImpl.APPEND
- : FileChannelImpl.WRITE));
+ this (new File(path), append);
}
/**
@@ -130,7 +124,7 @@
public FileOutputStream (File file)
throws SecurityException, FileNotFoundException
{
- this (file.getPath(), false);
+ this (file, false);
}
/**
@@ -156,7 +150,17 @@
public FileOutputStream (File file, boolean append)
throws FileNotFoundException
{
- this (file.getPath(), append);
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkWrite(file.getPath());
+
+ if (file.isDirectory())
+ throw new FileNotFoundException(file.getPath() + " is a directory");
+
+ ch = new FileChannelImpl (file.getPath(), (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
}
/**