sfFTP Class Reference

#include <FTP.hpp>

Inheritance diagram for sfFTP:

sfNonCopyable List of all members.

Public Types

enum  TransferMode {
  Binary,
  Ascii,
  Ebcdic
}

Public Member Functions

 sfFTP (Listener *FTPListener=NULL)
 ~sfFTP ()
bool Connect (const sfIPAddress &Server, unsigned int Port=21)
bool Login (const std::string &UserName, const std::string &Password)
bool Disconnect ()
bool KeepAlive ()
bool GetWorkingDirectory (std::string &Directory)
bool GetDirectoryListing (std::vector< std::string > &Listing, const std::string &Directory="")
bool ChangeDirectory (const std::string &Directory)
bool ParentDirectory ()
bool MakeDirectory (const std::string &Name)
bool DeleteDirectory (const std::string &Name)
bool RenameFile (const std::string &File, const std::string &NewName)
bool RemoveFile (const std::string &Name)
bool Download (const std::string &DistantFile, const std::string &DestPath, TransferMode Mode=Binary)
bool Upload (const std::string &LocalFile, const std::string &DestPath, TransferMode Mode=Binary)

Classes

class  DataChannel
class  Listener

Detailed Description

sfFTP wraps the FTP protocol to allow easy file transfers over the network

Definition at line 41 of file FTP.hpp.


Member Enumeration Documentation

enum sfFTP::TransferMode

Enumeration of transfer modes

Enumerator:
Binary 
Ascii 
Ebcdic 

Definition at line 76 of file FTP.hpp.


Constructor & Destructor Documentation

sfFTP::sfFTP ( Listener FTPListener = NULL  ) 

Default constructor

Parameters:
FTPListener : Listener (NULL by default)

Definition at line 39 of file FTP.cpp.

sfFTP::~sfFTP (  ) 

Destructor

Definition at line 49 of file FTP.cpp.

References Disconnect().


Member Function Documentation

bool sfFTP::Connect ( const sfIPAddress Server,
unsigned int  Port = 21 
)

Connect to the specified FTP server

Parameters:
Server : FTP server IP address
Port : Port used for connection (21 by default)
Returns:
True on success, false otherwise

Definition at line 58 of file FTP.cpp.

References sfSocketTCP::Connect(), and sfIPAddress::IsValid().

bool sfFTP::Login ( const std::string &  UserName,
const std::string &  Password 
)

Log in using a username and a password

Parameters:
UserName : User name
Password : Password

Definition at line 82 of file FTP.cpp.

bool sfFTP::Disconnect (  ) 

Close the connection with FTP server

Returns:
True on success, false otherwise

Definition at line 92 of file FTP.cpp.

References sfSocketTCP::Close().

Referenced by ~sfFTP().

bool sfFTP::KeepAlive (  ) 

Send a null command just to prevent from being disconnected

Returns:
True on success, false otherwise

Definition at line 106 of file FTP.cpp.

bool sfFTP::GetWorkingDirectory ( std::string &  Directory  ) 

Get the current working directory

Parameters:
Directory : String to fill with the retrieved directory
Returns:
True on success, false otherwise

Definition at line 115 of file FTP.cpp.

bool sfFTP::GetDirectoryListing ( std::vector< std::string > &  Listing,
const std::string &  Directory = "" 
)

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

Parameters:
Listing : Array of strings to fill with the directory listing
Directory : Directory to list ("" by default, the current one)
Returns:
True on success, false otherwise

Definition at line 137 of file FTP.cpp.

References Ascii.

bool sfFTP::ChangeDirectory ( const std::string &  Directory  ) 

Change the current working directory

Parameters:
Directory : New directory, relative to the current one
Returns:
True on success, false otherwise

Definition at line 178 of file FTP.cpp.

bool sfFTP::ParentDirectory (  ) 

Go to the parent directory of the current one

Returns:
True on success, false otherwise

Definition at line 187 of file FTP.cpp.

bool sfFTP::MakeDirectory ( const std::string &  Name  ) 

Create a new directory

Parameters:
Name : Name of the directory to create
Returns:
True on success, false otherwise

Definition at line 196 of file FTP.cpp.

bool sfFTP::DeleteDirectory ( const std::string &  Name  ) 

Remove an existing directory

Parameters:
Name : Name of the directory to remove
Returns:
True on success, false otherwise

Definition at line 205 of file FTP.cpp.

bool sfFTP::RenameFile ( const std::string &  File,
const std::string &  NewName 
)

Rename a file

Parameters:
File : File to rename
NewName : New name
Returns:
True on success, false otherwise

Definition at line 214 of file FTP.cpp.

bool sfFTP::RemoveFile ( const std::string &  Name  ) 

Remove an existing file

Parameters:
Name : File to remove
Returns:
True on success, false otherwise

Definition at line 224 of file FTP.cpp.

bool sfFTP::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 (binary by default)
Returns:
True on success, false otherwise

Definition at line 233 of file FTP.cpp.

bool sfFTP::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 (binary by default)
Returns:
True on success, false otherwise

Definition at line 274 of file FTP.cpp.


The documentation for this class was generated from the following files:
Generated for SFML by  doxygen 1.5.2