Hi,
Committed.
Regards,
Jeroen
2006-02-17 Jeroen Frijters <[EMAIL PROTECTED]>
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.
Index: gnu/java/net/protocol/ftp/FTPURLConnection.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java,v
retrieving revision 1.4
diff -u -r1.4 FTPURLConnection.java
--- gnu/java/net/protocol/ftp/FTPURLConnection.java 2 Jul 2005 20:32:13
-0000 1.4
+++ gnu/java/net/protocol/ftp/FTPURLConnection.java 15 Feb 2006 20:24:06
-0000
@@ -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 @@
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 @@
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 @@
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 @@
{
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)