|
|
|
@ -1347,12 +1347,12 @@ public class FTPClient {
|
|
|
|
|
// read file system data
|
|
|
|
|
String line;
|
|
|
|
|
final ArrayList<String> files = new ArrayList<String>();
|
|
|
|
|
try {
|
|
|
|
|
while ((line = ClientStream.readLine()) != null) {
|
|
|
|
|
if (!line.startsWith("total ")) {
|
|
|
|
|
files.add(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// after stream is empty we should get control completion echo
|
|
|
|
|
/*reply =*/ receive();
|
|
|
|
|
|
|
|
|
@ -1361,9 +1361,8 @@ public class FTPClient {
|
|
|
|
|
// shutdown connection
|
|
|
|
|
ClientStream.close(); // Closing the returned InputStream will
|
|
|
|
|
closeDataSocket(); // close the associated socket.
|
|
|
|
|
|
|
|
|
|
// if (!success) throw new IOException(reply);
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
}
|
|
|
|
|
files.trimToSize();
|
|
|
|
|
return files;
|
|
|
|
|
}
|
|
|
|
@ -2518,33 +2517,25 @@ public class FTPClient {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StringBuilder dirhtml(String remotePath) {
|
|
|
|
|
public StringBuilder dirhtml(String remotePath) throws IOException {
|
|
|
|
|
// returns a directory listing using an existing connection
|
|
|
|
|
try {
|
|
|
|
|
if (isFolder(remotePath) && '/' != remotePath.charAt(remotePath.length()-1)) {
|
|
|
|
|
remotePath += '/';
|
|
|
|
|
}
|
|
|
|
|
String pwd = pwd();
|
|
|
|
|
final List<String> list = list(remotePath, true);
|
|
|
|
|
if (remotesystem == null) {
|
|
|
|
|
sys();
|
|
|
|
|
}
|
|
|
|
|
if (remotesystem == null) try {sys();} catch (IOException e) {}
|
|
|
|
|
final String base = "ftp://" + ((account.equals("anonymous")) ? "" : (account + ":" + password + "@"))
|
|
|
|
|
+ host + ((port == 21) ? "" : (":" + port)) + ((remotePath.length() > 0 && remotePath.charAt(0) == '/') ? "" : pwd() + "/")
|
|
|
|
|
+ host + ((port == 21) ? "" : (":" + port)) + ((remotePath.length() > 0 && remotePath.charAt(0) == '/') ? "" : pwd + "/")
|
|
|
|
|
+ remotePath;
|
|
|
|
|
|
|
|
|
|
return dirhtml(base, remotemessage, remotegreeting, remotesystem, list, true);
|
|
|
|
|
} catch (final java.security.AccessControlException e) {
|
|
|
|
|
return null;
|
|
|
|
|
} catch (final IOException e) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static StringBuilder dirhtml(
|
|
|
|
|
final String host, final int port, final String remotePath,
|
|
|
|
|
final String account, final String password) {
|
|
|
|
|
final String account, final String password) throws IOException {
|
|
|
|
|
// opens a new connection and returns a directory listing as html
|
|
|
|
|
try {
|
|
|
|
|
final FTPClient c = new FTPClient();
|
|
|
|
|
c.open(host, port);
|
|
|
|
|
c.login(account, password);
|
|
|
|
@ -2552,11 +2543,6 @@ public class FTPClient {
|
|
|
|
|
final StringBuilder page = c.dirhtml(remotePath);
|
|
|
|
|
c.quit();
|
|
|
|
|
return page;
|
|
|
|
|
} catch (final java.security.AccessControlException e) {
|
|
|
|
|
return null;
|
|
|
|
|
} catch (final IOException e) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static StringBuilder dirhtml(
|
|
|
|
@ -2619,12 +2605,11 @@ public class FTPClient {
|
|
|
|
|
dir(host, remotePath, "anonymous", "anomic");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void dirAnonymousHtml(final String host, final int port, final String remotePath,
|
|
|
|
|
final String htmloutfile) {
|
|
|
|
|
public static void dirAnonymousHtml(final String host, final int port, final String remotePath, final String htmloutfile) {
|
|
|
|
|
try {
|
|
|
|
|
final StringBuilder page = dirhtml(host, port, remotePath, "anonymous", "anomic");
|
|
|
|
|
final File file = new File(htmloutfile);
|
|
|
|
|
FileOutputStream fos;
|
|
|
|
|
try {
|
|
|
|
|
fos = new FileOutputStream(file);
|
|
|
|
|
fos.write(page.toString().getBytes());
|
|
|
|
|
fos.close();
|
|
|
|
|