summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@sumatra.nl>2006-02-17 09:13:45 +0000
committerJeroen Frijters <jeroen@sumatra.nl>2006-02-17 09:13:45 +0000
commit5626013b892d6612c420253b849029d96e13283c (patch)
tree54fb5c597705eafedc0948c437de9625cc519e8c /gnu
parent79e5a71bb2835ac1e3c293f5cec23f57235aa7f6 (diff)
downloadclasspath-5626013b892d6612c420253b849029d96e13283c.tar.gz
2006-02-17 Jeroen Frijters <jeroen@frijters.net>
Fixes PR 25752 * gnu/java/net/protocol/ftp/FTPURLConnection.java (connect): Changed to use SystemProperties. (getInputStream): Try changeWorkingDirectory to figure out if url is a directory, if not use retrieve. (getOutputStream): Don't worry about directories, simply always try to do a store.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/java/net/protocol/ftp/FTPURLConnection.java43
1 files changed, 9 insertions, 34 deletions
diff --git a/gnu/java/net/protocol/ftp/FTPURLConnection.java b/gnu/java/net/protocol/ftp/FTPURLConnection.java
index 62c40f19e..e30d3f4ac 100644
--- a/gnu/java/net/protocol/ftp/FTPURLConnection.java
+++ b/gnu/java/net/protocol/ftp/FTPURLConnection.java
@@ -1,5 +1,5 @@
/* FTPURLConnection.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.java.net.protocol.ftp;
+import gnu.classpath.SystemProperties;
import gnu.java.net.GetLocalHostAction;
-import gnu.java.security.action.GetPropertyAction;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
@@ -113,11 +113,9 @@ public class FTPURLConnection
else
{
username = "anonymous";
- PrivilegedAction a = new GetPropertyAction("user.name");
- String systemUsername =(String) AccessController.doPrivileged(a);
- a = new GetLocalHostAction();
+ GetLocalHostAction a = new GetLocalHostAction();
InetAddress localhost =(InetAddress) AccessController.doPrivileged(a);
- password = systemUsername + "@" +
+ password = SystemProperties.getProperty("user.name") + "@" +
((localhost == null) ? "localhost" : localhost.getHostName());
}
connection = new FTPConnection(host, port);
@@ -167,24 +165,13 @@ public class FTPURLConnection
connect();
}
String path = url.getPath();
- String filename = null;
- int lsi = path.lastIndexOf('/');
- if (lsi != -1)
+ if (connection.changeWorkingDirectory(path))
{
- filename = path.substring(lsi + 1);
- path = path.substring(0, lsi);
- if (!connection.changeWorkingDirectory(path))
- {
- throw new FileNotFoundException(path);
- }
- }
- if (filename != null && filename.length() > 0)
- {
- return this.new ClosingInputStream(connection.retrieve(filename));
+ return this.new ClosingInputStream(connection.list(null));
}
else
{
- return this.new ClosingInputStream(connection.list(null));
+ return this.new ClosingInputStream(connection.retrieve(path));
}
}
@@ -198,20 +185,8 @@ public class FTPURLConnection
{
connect();
}
- String dir = url.getPath();
- String filename = url.getFile();
- if (!connection.changeWorkingDirectory(dir))
- {
- throw new FileNotFoundException(dir);
- }
- if (filename != null)
- {
- return this.new ClosingOutputStream(connection.store(filename));
- }
- else
- {
- throw new FileNotFoundException(filename);
- }
+ String path = url.getPath();
+ return this.new ClosingOutputStream(connection.store(path));
}
public String getRequestProperty(String key)