tango.net.ftp.FtpClient

Author:

Lester L. Martin II UWB, bobef

License:

BSD style: see license.txt Initial release: August 8, 2008
alias void delegate(in size_t pos) FtpProgress
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.

Parameters:

posthe 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 : 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.

Parameters:

messagethe exception message
codethe code (5xx for fatal errors)
this(FtpResponse r)
Construct an FtpException based on a response.

Parameters:

rthe server response
string toString() [override]
A string representation of the error.
class FTPConnection : Telnet
Seriously changed Since: 0.99.8 Documentation pending
TimeSpan timeout() [public, @property]
Added Since: 0.99.8
void timeout(TimeSpan t) [public, @property]
Added Since: 0.99.8
TimeSpan shutdownTime() [public]
Added Since: 0.99.8
FtpFeature[] supportedFeatures() [public]
Added Since: 0.99.8
void exception(string message) [override]
Changed Since: 0.99.8
void exception(FtpResponse fr)
Changed Since: 0.99.8
this(FtpAddress fad) [public]
Added Since: 0.99.8
void connect(FtpAddress fad) [public]
Added Since: 0.99.8
void connect(const(char)[] hostname, const(char)[] username = "anonymous", const(char)[] password = "anonymous@anonymous", uint port = 21) [public]
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
Socket getDataSocket() [protected]
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
void prepareDataSocket(ref Socket data) [protected]
Prepare a data socket for use. This modifies the socket in some cases.

Parameters:

datathe data listener socket Changed Since: 0.99.8
void finishDataCommand(Socket data) [public]
Changed Since: 0.99.8
Socket processDataCommand(const(char)[] command, const(char)[][] parameters...) [public]
Changed Since: 0.99.8
void readStream(Socket data, OutputStream stream, FtpProgress progress = null) [protected]
Changed Since: 0.99.8
void sendStream(Socket data, InputStream stream, FtpProgress progress = null) [protected]
Changed Since: 0.99.8
void put(const(char)[] path, InputStream stream = null, FtpProgress progress = null, FtpFormat format = image) [public]
Store data from a stream on the server. Calling this function will change the current data transfer format.

Parameters:

paththe path to the remote file
streamdata to store, or null for a blank file
progressa delegate to call with progress information
formatwhat format to send the data in
void append(const(char)[] path, InputStream stream, FtpProgress progress = null, FtpFormat format = image) [public]
Append data to a file on the server. Calling this function will change the current data transfer format.

Parameters:

paththe path to the remote file
streamdata to append to the file
progressa delegate to call with progress information
formatwhat format to send the data in
void restartSeek(size_t offset) [public]
Seek to a byte offset for the next transfer.

Parameters:

offsetthe number of bytes to seek forward
void allocate(long bytes) [public]
Allocate space for a file. After calling this, append() or put() should be the next command.

Parameters:

bytesthe number of bytes to allocate
void get(const(char)[] path, const(char)[] local_file, FtpProgress progress = null, FtpFormat format = image) [public]
Retrieve a remote file's contents into a local file. Calling this function will change the current data transfer format.

Parameters:

paththe path to the remote file
local_filethe path to the local file
progressa delegate to call with progress information
formatwhat format to read the data in
void enableUTF8() [public]
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 = image) [public]
Retrieve a remote file's contents into a local file. Calling this function will change the current data transfer format.

Parameters:

paththe path to the remote file
streamstream to write the data to
progressa delegate to call with progress information
formatwhat format to read the data in
InputStream input(const(char)[] path) [public]
Added Since: 0.99.8
OutputStream output(const(char)[] path) [public]
Added Since: 0.99.8