OSDN Git Service

2004-04-20 Jeroen Frijters <jeroen@frijters.net>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Apr 2004 13:43:35 +0000 (13:43 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Apr 2004 13:43:35 +0000 (13:43 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80901 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/io/FileDescriptor.java
libjava/java/io/FileOutputStream.java

index b64d0c1..84a66b1 100644 (file)
@@ -1,3 +1,15 @@
+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.
+
 2004-04-20  Michael Koch  <konqueror@gmx.de>
 
        * java/net/Authenticator.java,
index be86593..35a4785 100644 (file)
@@ -83,6 +83,14 @@ public final class FileDescriptor
   /**
    * 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 final class FileDescriptor
    */
   public boolean valid ()
   {
-    return channel.isOpen();
+    return channel != null && channel.isOpen();
   }
 }
index a8c4b76..8942871 100644 (file)
@@ -81,13 +81,7 @@ public class FileOutputStream extends OutputStream
   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 class FileOutputStream extends OutputStream
   public FileOutputStream (File file)
     throws SecurityException, FileNotFoundException
   {
-    this (file.getPath(), false);
+    this (file, false);
   }
 
   /**
@@ -156,7 +150,17 @@ public class FileOutputStream extends OutputStream
   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));
   }
 
   /**