[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/25752] New: ftpurlconnection well broke
From: |
si at naims dot co dot uk |
Subject: |
[Bug classpath/25752] New: ftpurlconnection well broke |
Date: |
11 Jan 2006 17:37:58 -0000 |
on ftp connect get "wrong number of parameters" from the host, because the
"change working directory" CWD, has been called without a parameter, this
happens because the code in ftpurlconnection thinks that this "\index.html"
refers to a directory of "", on further investigation this all happens because
of a basic misunderstanding of what URL.getFile() and URL.getPath() return,
both getinputstrream and getoutputstream suffer from this and need rewriting.
FWIW, (see original code below) i dont think you need CWD at all, because both
LIST and RET can cope with a path, but you will need to use LIST to see if you
are dealing with a file or a directory, because this is the only reliable way.
/**
* Returns an input stream that reads from this open connection.
*/
public InputStream getInputStream()
throws IOException
{
if (!connected)
{
connect();
}
String path = url.getPath();
String filename = null;
int lsi = path.lastIndexOf('/');
if (lsi != -1)
{
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));
}
else
{
return this.new ClosingInputStream(connection.list(null));
}
}
/**
* Returns an output stream that writes to this connection.
*/
public OutputStream getOutputStream()
throws IOException
{
if (!connected)
{
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);
}
--
Summary: ftpurlconnection well broke
Product: classpath
Version: unspecified
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: si at naims dot co dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25752
- [Bug classpath/25752] New: ftpurlconnection well broke,
si at naims dot co dot uk <=