sfFTP Class Reference

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

#include <FTP.hpp>

Inheritance diagram for sfFTP:

sfNonCopyable List of all members.

Public Types

enum  TransferMode {
  Binary,
  Ascii,
  Ebcdic
}
 Enumeration of transfer modes. More...

Public Member Functions

 sfFTP (Listener *FTPListener=NULL)
 Default constructor.
 ~sfFTP ()
 Destructor.
bool Connect (const sfIPAddress &Server, unsigned short Port=21)
 Connect to the specified FTP server.
bool Login (const std::string &UserName, const std::string &Password)
 Log in using a username and a password.
bool Disconnect ()
 Close the connection with FTP server.
bool KeepAlive ()
 Send a null command just to prevent from being disconnected.
bool GetWorkingDirectory (std::string &Directory)
 Get the current working directory.
bool GetDirectoryListing (std::vector< std::string > &Listing, const std::string &Directory="")
 Get the contents of the given directory (subdirectories and files).
bool ChangeDirectory (const std::string &Directory)
 Change the current working directory.
bool ParentDirectory ()
 Go to the parent directory of the current one.
bool MakeDirectory (const std::string &Name)
 Create a new directory.
bool DeleteDirectory (const std::string &Name)
 Remove an existing directory.
bool RenameFile (const std::string &File, const std::string &NewName)
 Rename a file.
bool RemoveFile (const std::string &Name)
 Remove an existing file.
bool Download (const std::string &DistantFile, const std::string &DestPath, TransferMode Mode=Binary)
 Download a file from the server.
bool Upload (const std::string &LocalFile, const std::string &DestPath, TransferMode Mode=Binary)
 Upload a file to the server.

Friends

class DataChannel

Classes

class  DataChannel
 Utility class for exchanging datas with the server on the data channel.
class  Listener
 Base class for FTP listeners -- inherits from it if you want to get the FTP server responses. More...

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.


Member Function Documentation

bool sfFTP::Connect ( const sfIPAddress Server,
unsigned short  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.

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.

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.

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: