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]

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


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

Hi list,


I just commited the attached patch to merge 
gnu.java.net.protocol.file.Connection more with classpath again.


Michael


2004-09-10  Dalibor Topic <robilad@kaffe.org>

	* gnu/java/net/protocol/file/Connection.java (permission): New field.
	(DEFAULT_PERMISSION): New constant.
	(Connection): Create a FilePermission with permission to read file.

2004-09-10  Michael Koch  <konqueror@gmx.de>

	* gnu/java/net/protocol/file/Connection.java
	(getLastModified): Moved around.
	(getPermission): Return stored permission.
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBQYxAWSOgCCdjSDsRAhMzAJ9vIR/J/v7+kksrHPYu/TIwSt4yeACfRMlz
2RQDJmcTPs4Fp7GMiNS8Jw4=
=+V8E
-----END PGP SIGNATURE-----
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.8
diff -u -r1.8 Connection.java
--- gnu/java/net/protocol/file/Connection.java	10 Sep 2004 07:20:09 -0000	1.8
+++ gnu/java/net/protocol/file/Connection.java	10 Sep 2004 11:05:36 -0000
@@ -69,6 +69,11 @@
 public class Connection extends URLConnection
 {
   /**
+   * Default permission for a file
+   */
+  private static final String DEFAULT_PERMISSION = "read";
+
+  /**
    * HTTP-style DateFormat, used to format the last-modified header.
    */
   private static SimpleDateFormat dateFormat
@@ -93,11 +98,18 @@
   private OutputStream outputStream;
   
   /**
+   * 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);
   }
   
   /**
@@ -187,6 +199,26 @@
   }
 
   /**
+   * Get the last modified time of the resource.
+   *
+   * @return the time since epoch that the resource was modified.
+   */
+  public long getLastModified()
+  {
+    try
+      {
+	if (!connected)
+	  connect();
+
+	return file.lastModified();
+      }
+    catch (IOException e)
+      {
+	return -1;
+      }
+  }
+  
+  /**
    *  Get an http-style header field. Just handle a few common ones. 
    */
   public String getHeaderField(String field)
@@ -224,30 +256,10 @@
   {
     try
       {
- 	if (!connected)
- 	  connect();
-
-	return (int) file.length();
-      }
-    catch (IOException e)
-      {
- 	return -1;
-      }
-  }
-
-  /**
-   * Get the last modified time of the resource.
-   *
-   * @return the time since epoch that the resource was modified.
-   */
-  public long getLastModified()
-  {
-    try
-      {
 	if (!connected)
 	  connect();
         
-	return file.lastModified();
+	return (int) file.length();
       }
     catch (IOException e)
       {
@@ -265,6 +277,6 @@
    */
   public Permission getPermission() throws IOException
   {
-    return new FilePermission(getURL().getFile(), "read");
+    return permission;
   }
 }

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