diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 21:03:00 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 21:03:00 +0000 |
commit | 184b7bf54c26c7366ba668d7788610fb5111846e (patch) | |
tree | b58fc962d6b987c3d38b9da9dd5fe177155c159a /libjava/java/net | |
parent | fc6c4b2c5fcf758f99662a37b3f23bf1def6a9cb (diff) | |
download | gcc-184b7bf54c26c7366ba668d7788610fb5111846e.tar.gz |
2005-04-27 Chris Burdess <dog@gnu.org>
* gnu/java/net/protocol/file/Connection.java: Return correct content
length for directory listing.
* java/net/URLClassLoader.java: Correction for URLClassLoader, bug
#11285: return valid URLs for directories.i
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98884 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net')
-rw-r--r-- | libjava/java/net/URLClassLoader.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 9593e7d0fb0..4b9599816a9 100644 --- a/libjava/java/net/URLClassLoader.java +++ b/libjava/java/net/URLClassLoader.java @@ -610,7 +610,7 @@ public class URLClassLoader extends SecureClassLoader Resource getResource(String name) { File file = new File(dir, name); - if (file.exists() && ! file.isDirectory()) + if (file.exists()) return new FileResource(this, name, file); return null; } @@ -628,11 +628,36 @@ public class URLClassLoader extends SecureClassLoader InputStream getInputStream() throws IOException { + // Delegate to the URL content handler mechanism to retrieve an + // HTML representation of the directory listing if a directory + if (file.isDirectory()) + { + URL url = getURL(); + return url.openStream(); + } + // Otherwise simply return a FileInputStream return new FileInputStream(file); } public int getLength() { + // Delegate to the URL content handler mechanism to retrieve the + // length of the HTML representation of the directory listing if + // a directory, or -1 if an exception occurs opening the directory. + if (file.isDirectory()) + { + URL url = getURL(); + try + { + URLConnection connection = url.openConnection(); + return connection.getContentLength(); + } + catch (IOException e) + { + return -1; + } + } + // Otherwise simply return the file length return (int) file.length(); } |