Skip to content

Commit

Permalink
added size method to ftpc
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2508 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Sep 7, 2006
1 parent 087f751 commit 1e7fd48
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions source/de/anomic/net/ftpc.java
Expand Up @@ -1311,6 +1311,34 @@ public boolean RECV() {
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>");
Expand Down

0 comments on commit 1e7fd48

Please sign in to comment.