sf::Ftp Class Reference

This class provides methods for manipulating the FTP protocol (described in RFC 959). More...

#include <Ftp.hpp>

Inheritance diagram for sf::Ftp:
sf::NonCopyable

List of all members.

Classes

class  DataChannel
class  DirectoryResponse
 Specialization of FTP response returning a directory. More...
class  ListingResponse
 Specialization of FTP response returning a filename lisiting. More...
class  Response
 This class wraps a FTP response, which is basically :

  • a status code
  • a message.
More...

Public Types

enum  TransferMode {
  Binary,
  Ascii,
  Ebcdic
}
 

Enumeration of transfer modes.

More...

Public Member Functions

 ~Ftp ()
 Destructor -- close the connection with the server.
Response Connect (const IPAddress &server, unsigned short port=21, float timeout=0.f)
 Connect to the specified FTP server.
Response Login ()
 Log in using anonymous account.
Response Login (const std::string &name, const std::string &password)
 Log in using a username and a password.
Response Disconnect ()
 Close the connection with FTP server.
Response KeepAlive ()
 Send a null command just to prevent from being disconnected.
DirectoryResponse GetWorkingDirectory ()
 Get the current working directory.
ListingResponse GetDirectoryListing (const std::string &directory="")
 Get the contents of the given directory (subdirectories and files).
Response ChangeDirectory (const std::string &directory)
 Change the current working directory.
Response ParentDirectory ()
 Go to the parent directory of the current one.
Response MakeDirectory (const std::string &name)
 Create a new directory.
Response DeleteDirectory (const std::string &name)
 Remove an existing directory.
Response RenameFile (const std::string &file, const std::string &newName)
 Rename a file.
Response DeleteFile (const std::string &name)
 Remove an existing file.
Response Download (const std::string &distantFile, const std::string &destPath, TransferMode mode=Binary)
 Download a file from the server.
Response Upload (const std::string &localFile, const std::string &destPath, TransferMode mode=Binary)
 Upload a file to the server.

Friends

class DataChannel

Detailed Description

This class provides methods for manipulating the FTP protocol (described in RFC 959).

It provides easy access and transfers to remote directories and files on a FTP server

Definition at line 47 of file Ftp.hpp.


Member Enumeration Documentation

Enumeration of transfer modes.

Enumerator:
Binary 

Binary mode (file is transfered as a sequence of bytes).

Ascii 

Text mode using ASCII encoding.

Ebcdic 

Text mode using EBCDIC encoding.

Definition at line 54 of file Ftp.hpp.


Constructor & Destructor Documentation

sf::Ftp::~Ftp (  ) 

Destructor -- close the connection with the server.

Definition at line 186 of file Ftp.cpp.


Member Function Documentation

Ftp::Response sf::Ftp::ChangeDirectory ( const std::string &  directory  ) 

Change the current working directory.

Parameters:
directory : New directory, relative to the current one
Returns:
Server response to the request

Definition at line 291 of file Ftp.cpp.

Ftp::Response sf::Ftp::Connect ( const IPAddress server,
unsigned short  port = 21,
float  timeout = 0.f 
)

Connect to the specified FTP server.

Parameters:
server : FTP server to connect to
port : Port used for connection (21 by default, standard FTP port)
timeout : Maximum time to wait, in seconds (0 by default, means no timeout)
Returns:
Server response to the request

Definition at line 195 of file Ftp.cpp.

Ftp::Response sf::Ftp::DeleteDirectory ( const std::string &  name  ) 

Remove an existing directory.

Parameters:
Name : Name of the directory to remove
Returns:
Server response to the request

Definition at line 318 of file Ftp.cpp.

Ftp::Response sf::Ftp::DeleteFile ( const std::string &  name  ) 

Remove an existing file.

Parameters:
name : File to remove
Returns:
Server response to the request

Definition at line 340 of file Ftp.cpp.

Ftp::Response sf::Ftp::Disconnect (  ) 

Close the connection with FTP server.

Returns:
Server response to the request

Definition at line 231 of file Ftp.cpp.

Ftp::Response sf::Ftp::Download ( const std::string &  distantFile,
const std::string &  destPath,
TransferMode  mode = Binary 
)

Download a file from the server.

Parameters:
distantFile : Path of the distant file to download
destPath : Where to put to file on the local computer
mode : Transfer mode
Returns:
Server response to the request

Definition at line 349 of file Ftp.cpp.

Ftp::ListingResponse sf::Ftp::GetDirectoryListing ( const std::string &  directory = ""  ) 

Get the contents of the given directory (subdirectories and files).

Parameters:
directory : Directory to list ("" by default, the current one)
Returns:
Server response to the request

Definition at line 264 of file Ftp.cpp.

Ftp::DirectoryResponse sf::Ftp::GetWorkingDirectory (  ) 

Get the current working directory.

Returns:
Server response to the request

Definition at line 254 of file Ftp.cpp.

Ftp::Response sf::Ftp::KeepAlive (  ) 

Send a null command just to prevent from being disconnected.

Returns:
Server response to the request

Definition at line 245 of file Ftp.cpp.

Ftp::Response sf::Ftp::Login ( const std::string &  name,
const std::string &  password 
)

Log in using a username and a password.

Parameters:
name : User name
password : Password
Returns:
Server response to the request

Definition at line 218 of file Ftp.cpp.

Ftp::Response sf::Ftp::Login (  ) 

Log in using anonymous account.

Returns:
Server response to the request

Definition at line 209 of file Ftp.cpp.

Ftp::Response sf::Ftp::MakeDirectory ( const std::string &  name  ) 

Create a new directory.

Parameters:
name : Name of the directory to create
Returns:
Server response to the request

Definition at line 309 of file Ftp.cpp.

Ftp::Response sf::Ftp::ParentDirectory (  ) 

Go to the parent directory of the current one.

Returns:
Server response to the request

Definition at line 300 of file Ftp.cpp.

Ftp::Response sf::Ftp::RenameFile ( const std::string &  file,
const std::string &  newName 
)

Rename a file.

Parameters:
file : File to rename
newName : New name
Returns:
Server response to the request

Definition at line 327 of file Ftp.cpp.

Ftp::Response sf::Ftp::Upload ( const std::string &  localFile,
const std::string &  destPath,
TransferMode  mode = Binary 
)

Upload a file to the server.

Parameters:
localFile : Path of the local file to upload
destPath : Where to put to file on the server
mode : Transfer mode
Returns:
Server response to the request

Definition at line 397 of file Ftp.cpp.


The documentation for this class was generated from the following files: