commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Better FileInputStream constructor checks.


From: Mark Wielaard
Subject: [PATCH] Better FileInputStream constructor checks.
Date: Fri, 26 Dec 2003 14:12:44 +0100

Hi all,

Another small fix from kaffe:

2003-12-26  Guilhem Lavaux  <address@hidden>

        * java/io/FileInputStream.java (FileInputStream(String)): Call
        FileInputStream(File).
        (FileInputStream(File)): Check whether the argument is a directory.

I am checking this in.

Cheers,

Mark
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/FileInputStream.java,v
retrieving revision 1.25
diff -u -r1.25 FileInputStream.java
--- java/io/FileInputStream.java        14 Jul 2003 05:56:27 -0000      1.25
+++ java/io/FileInputStream.java        26 Dec 2003 13:10:11 -0000
@@ -79,11 +79,7 @@
    */
   public FileInputStream(String name) throws FileNotFoundException
   {
-    SecurityManager s = System.getSecurityManager();
-    if (s != null)
-      s.checkRead(name);
-
-    fd = new FileDescriptor(name, FileDescriptor.READ);
+    this(new File(name));
   }
 
   /**
@@ -104,7 +100,14 @@
    */
   public FileInputStream(File file) throws FileNotFoundException
   {
-    this(file.getPath());
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkRead(file.getPath());
+
+    if (file.isDirectory())
+      throw new FileNotFoundException(file.getPath() + " is a directory");
+
+    fd = new FileDescriptor(file.getPath(), FileDescriptor.READ);
   }
 
   /**

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]