diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-10 11:06:38 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-10 11:06:38 +0000 |
commit | eaf7e1b7de846efae0df649cfcff4758e8dd94db (patch) | |
tree | 2797b4d2b91f5763c932b9f9b6933f44598fbaae /libjava | |
parent | 2045cdd44d272c6b5330210e6a60aa16f769b850 (diff) | |
download | gcc-eaf7e1b7de846efae0df649cfcff4758e8dd94db.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87291 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 12 | ||||
-rw-r--r-- | libjava/gnu/java/net/protocol/file/Connection.java | 56 |
2 files changed, 46 insertions, 22 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5c815e9bfa9..1bd4ccc34c5 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,15 @@ +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. + 2004-09-10 Michael Koch <konqueror@gmx.de> * Makefile.in: Regenerate. diff --git a/libjava/gnu/java/net/protocol/file/Connection.java b/libjava/gnu/java/net/protocol/file/Connection.java index 3927130101b..2754717bb14 100644 --- a/libjava/gnu/java/net/protocol/file/Connection.java +++ b/libjava/gnu/java/net/protocol/file/Connection.java @@ -69,6 +69,11 @@ import java.util.Locale; 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 @@ public class Connection extends URLConnection 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 @@ public class Connection extends URLConnection } /** + * 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 @@ public class Connection extends URLConnection { 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 class Connection extends URLConnection */ public Permission getPermission() throws IOException { - return new FilePermission(getURL().getFile(), "read"); + return permission; } } |