added size method to ftpc

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2508 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 087f7511f8
commit 1e7fd48afd

@ -1311,6 +1311,34 @@ cd ..
return GET();
}
public int size(String path) throws IOException {
// get the size of a file. If the given path targets to a directory, a -1 is returned
// this function is not supported by standard rfc 959. The method is descibed in
// http://www.ietf.org/internet-drafts/draft-ietf-ftpext-mlst-16.txt
// if the method is not supported by the target server, this throws an IOException with the
// server response as exception message
// send command to the control port
send("SIZE " + path);
// read status of the command from the control port
String reply = receive();
// get status code
int status = Integer.parseInt(reply.substring(0, 3));
// starting data transaction
if (status == 213) {
try {
return Integer.parseInt(reply.substring(4));
} catch (NumberFormatException e) {
throw new IOException(reply);
}
} else {
throw new IOException(reply);
}
}
public boolean USER() {
if (cmd.length != 3) {
err.println(logPrefix + "---- Syntax: USER <user-name> <password>");

Loading…
Cancel
Save