This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: gnu.java.net.protocol.file.Connection


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to get 
gnu.java.net.protocol.file.Connection more in line with classpath.



Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/y3KtWSOgCCdjSDsRAi7/AKCS6ZDCDXFyXIIAqXQriE3Zx407tACeO+RQ
lCfgbEnIBqqesYWS6AZObWQ=
=77uq
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2385
diff -u -b -B -r1.2385 ChangeLog
--- ChangeLog	1 Dec 2003 15:28:21 -0000	1.2385
+++ ChangeLog	1 Dec 2003 15:49:58 -0000
@@ -1,3 +1,12 @@
+2003-12-01  Michael Koch  <konqueror@gmx.de>
+
+	* gnu/java/net/protocol/file/Connection.java
+	(fileIn): Documentation added.
+	(inputStream): Likewise.
+	(outputStream): Likewise.
+	(Connection): Likewise.
+	(connect): Simplified.
+
 2003-12-01  Thomas Fitzsimmons  <fitzsim@redhat.com>
 
 	* gnu/java/awt/peer/gtk/GtkImage.java (setDimensions,
Index: gnu/java/net/protocol/file/Connection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/protocol/file/Connection.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 Connection.java
--- gnu/java/net/protocol/file/Connection.java	18 Oct 2003 12:24:56 -0000	1.2
+++ gnu/java/net/protocol/file/Connection.java	1 Dec 2003 15:49:58 -0000
@@ -38,38 +38,71 @@
 */
 package gnu.java.net.protocol.file;
 
-import java.net.URL;
-import java.net.URLConnection;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FilePermission;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.Permission;
 import java.util.Map;
 import java.util.Vector;
 import java.util.Hashtable;
 import java.util.Enumeration;
 
 /**
+ * This subclass of java.net.URLConnection models a URLConnection via
+ * the "file" protocol.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
  * @author Warren Levy <warrenl@cygnus.com>
- * @date April 13, 1999.
  */
 public class Connection extends URLConnection
 {
-  private Hashtable hdrHash = new Hashtable();
-  private Vector hdrVec = new Vector();
-  private boolean gotHeaders = false;
+  /**
+   * Default permission for a file
+   */
+  private static final String DEFAULT_PERMISSION = "read";
+
+  /**
+   * This is a File object for this connection
+   */
   private File fileIn;
+
+  /**
+   * InputStream if we are reading from the file
+   */
   private InputStream inputStream;
+
+  /**
+   * OutputStream if we are writing to the file
+   */
   private OutputStream outputStream;
 
+  private Hashtable hdrHash = new Hashtable();
+  private Vector hdrVec = new Vector();
+  private boolean gotHeaders = false;
+
+  /**
+   * FilePermission to read the file
+   */
+  private FilePermission permission;
+
+  /**
+   * Calls superclass constructor to initialize.
+   */
   public Connection(URL url)
   {
     super (url);
+
+    permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
   }
   
   /**
@@ -82,8 +115,7 @@
       return;
     
     // If not connected, then file needs to be openned.
-    String fname = url.getFile();
-    fileIn = new File(fname);
+    fileIn = new File(getURL().getFile());
     if (doInput)
       inputStream = new BufferedInputStream(new FileInputStream(fileIn));
     if (doOutput)
@@ -238,4 +270,17 @@
     hdrHash.put(key.toLowerCase(), Long.toString(len));
   }
   
+  /**
+   * This method returns a <code>Permission</code> object representing the
+   * permissions required to access this URL.  This method returns a
+   * <code>java.io.FilePermission</code> for the file's path with a read
+   * permission.
+   *
+   * @return A Permission object
+   */
+  public Permission getPermission() throws IOException
+  {
+    return permission;
+  }
+
 } // class FileURLConnection

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]