tango.net.ftp.FtpClient

Author:
Lester L. Martin II UWB, bobef

License:
BSD style: Initial release: August 8, 2008

alias FtpProgress = void delegate(const(ulong) pos);
An FTP progress delegate.

You may need to add the restart position to this, and use SIZE to determine percentage completion. This only represents the number of bytes transferred.

Params:
pos the current offset into the stream

enum FtpFormat;
The format of data transfer.

ascii
Indicates ASCII NON PRINT format (line ending conversion to CRLF.)

image
Indicates IMAGE format (8 bit binary octets.)

struct FtpAddress;
A FtpAddress structure that contains all that is needed to access a FTPConnection; Contributed by Bobef

Since:
0.99.8

struct FtpResponse;
A server response, consisting of a code and a potentially multi-line message.

char[3] code;
The response code.

The digits in the response code can be used to determine status programatically.

First Digit (status): 1xx = a positive, but preliminary, reply 2xx = a positive reply indicating completion 3xx = a positive reply indicating incomplete status 4xx = a temporary negative reply 5xx = a permanent negative reply

Second Digit (subject): x0x = condition based on syntax x1x = informational x2x = connection x3x = authentication/process x5x = file system

const(char)[] message;
The message from the server.

With some responses, the message may contain parseable information. For example, this is true of the 257 response.

enum FtpConnectionType;
Active or passive connection mode.

active
Active - server connects to client on open port.

passive
Passive - server listens for a connection from the client.

struct FtpConnectionDetail;
Detail about the data connection.

This is used to properly send PORT and PASV commands.

FtpConnectionType type;
The type to be used.

Address address;
The address to give the server.

Address listen;
The address to actually listen on.

struct FtpFeature;
A supported feature of an FTP server.

const(char)[] command;
The command which is supported, e.g. SIZE.

const(char)[] params;
Parameters for this command; e.g. facts for MLST.

enum FtpFileType;
The type of a file in an FTP listing.

unknown
An unknown file or type (no type fact.)

file
A regular file, or similar.

cdir
The current directory (e.g. ., but not necessarily.)

pdir
A parent directory (usually "..".)

dir
Any other type of directory.

other
Another type of file. Consult the "type" fact.

struct FtpFileInfo;
Information about a file in an FTP listing.

const(char)[] name;
The filename.

FtpFileType type;
Its type.

ulong size;
Size in bytes (8 bit octets), or ulong.max if not available.

Since:
0.99.8

Time modify;
Modification time, if available.

Time create;
Creation time, if available (not often.)

const(char)[] mime;
The file's mime type, if known.

const(char)[][const(char)[]] facts;
An associative array of all facts returned by the server, lowercased.

class FtpException: object.Exception;
Changed location Since: 0.99.8 Documentation Pending

this(string message, char[3] code = "420");
Construct an FtpException based on a message and code.

Params:
string message the exception message
char[3] code the code (5xx for fatal errors)

this(FtpResponse r);
Construct an FtpException based on a response.

Params:
FtpResponse r the server response

string toString();
A string representation of the error.

class FTPConnection: tango.net.ftp.Telnet.Telnet;
Seriously changed Since: 0.99.8 Documentation pending

@property TimeSpan timeout();
Added Since: 0.99.8

@property void timeout(TimeSpan t);
Added Since: 0.99.8

TimeSpan shutdownTime();
Added Since: 0.99.8

FtpFeature[] supportedFeatures();
Added Since: 0.99.8

void exception(string message);
Changed Since: 0.99.8

void exception(FtpResponse fr);
Changed Since: 0.99.8

this(FtpAddress fad);
Added Since: 0.99.8

void connect(FtpAddress fad);
Added Since: 0.99.8

void connect(const(char)[] hostname, const(char)[] username = "anonymous", const(char)[] password = "anonymous@anonymous", uint port = 21);
Changed Since: 0.99.8

int exist(const(char)[] file);
Added Since: 0.99.8

Time modified(const(char)[] file);
Added Since: 0.99.8

protected Socket getDataSocket();
Get a data socket from the server.

This sends PASV/PORT as necessary.

Returns:
the data socket or a listener Changed Since: 0.99.8

Socket connectPassive();
Send a PASV and initiate a connection.

Returns:
a connected socket Changed Since: 0.99.8

protected void prepareDataSocket(ref Socket data);
Prepare a data socket for use.

This modifies the socket in some cases.

Params:
Socket data the data listener socket Changed Since: 0.99.8

void finishDataCommand(Socket data);
Changed Since: 0.99.8

Socket processDataCommand(const(char)[] command, const(char)[][] parameters...);
Changed Since: 0.99.8

protected void readStream(Socket data, OutputStream stream, FtpProgress progress = null);
Changed Since: 0.99.8

protected void sendStream(Socket data, InputStream stream, FtpProgress progress = null);
Changed Since: 0.99.8

void put(const(char)[] path, InputStream stream = null, FtpProgress progress = null, FtpFormat format = FtpFormat.image);
Store data from a stream on the server.

Calling this function will change the current data transfer format.

Params:
const(char)[] path the path to the remote file
InputStream stream data to store, or null for a blank file
FtpProgress progress a delegate to call with progress information
FtpFormat format what format to send the data in

void append(const(char)[] path, InputStream stream, FtpProgress progress = null, FtpFormat format = FtpFormat.image);
Append data to a file on the server.

Calling this function will change the current data transfer format.

Params:
const(char)[] path the path to the remote file
InputStream stream data to append to the file
FtpProgress progress a delegate to call with progress information
FtpFormat format what format to send the data in

void restartSeek(size_t offset);
Seek to a byte offset for the next transfer.

Params:
size_t offset the number of bytes to seek forward

void allocate(long bytes);
Allocate space for a file.

After calling this, append() or put() should be the next command.

Params:
long bytes the number of bytes to allocate

void get(const(char)[] path, const(char)[] local_file, FtpProgress progress = null, FtpFormat format = FtpFormat.image);
Retrieve a remote file's contents into a local file.

Calling this function will change the current data transfer format.

Params:
const(char)[] path the path to the remote file
const(char)[] local_file the path to the local file
FtpProgress progress a delegate to call with progress information
FtpFormat format what format to read the data in

void enableUTF8();
Enable UTF8 on servers that don't use this as default. Might need some work

void get(const(char)[] path, OutputStream stream, FtpProgress progress = null, FtpFormat format = FtpFormat.image);
Retrieve a remote file's contents into a local file.

Calling this function will change the current data transfer format.

Params:
const(char)[] path the path to the remote file
OutputStream stream stream to write the data to
FtpProgress progress a delegate to call with progress information
FtpFormat format what format to read the data in

InputStream input(const(char)[] path);
Added Since: 0.99.8

OutputStream output(const(char)[] path);
Added Since: 0.99.8


Page generated by Ddoc. (c) Lester L. Martin II UWB, bobef Based upon prior FtpClient.d