wfut  0.2.4
A client side C++ implementation of WFUT (WorldForge Update Tool).
WFUT::IO Class Reference

#include <IO.h>

Public Member Functions

int init ()
 
int shutdown ()
 
int poll ()
 
int downloadFile (const std::string &filename, const std::string &url, uLong expected_crc32)
 
int downloadFile (FILE *fp, const std::string &url, uLong expected_crc32)
 
int queueFile (const std::string &path, const std::string &filename, const std::string &url, uLong expected_crc32, bool executable)
 
int getMaxDownloads () const
 
void setMaxDownloads (int i)
 
void abortAll ()
 
void abortDownload (const std::string &)
 

Public Attributes

sigc::signal< void, const std::string &, const std::string & > DownloadComplete
 
sigc::signal< void, const std::string &, const std::string &, const std::string & > DownloadFailed
 

Detailed Description

The IO class wraps most of the CURL related calls, taking a URL to a file and writing it to a local file.

Definition at line 37 of file IO.h.

Member Function Documentation

◆ abortAll()

void WFUT::IO::abortAll ( )

Abort all current and pending downloads.

Definition at line 351 of file IO.cpp.

References abortDownload().

Referenced by WFUT::WFUTClient::abortAll().

◆ abortDownload()

void WFUT::IO::abortDownload ( const std::string &  filename)

Abort the download of the specified file.

Abort all current and pending downloads.

Definition at line 364 of file IO.cpp.

Referenced by abortAll(), and WFUT::WFUTClient::abortDownload().

◆ downloadFile() [1/2]

int WFUT::IO::downloadFile ( const std::string &  filename,
const std::string &  url,
uLong  expected_crc32 
)

Tell CURL to immediately download the file in the given URL and save it to the given filename, optionally checking the CRC32 value. This is a blocking call.

Parameters
filenameDestination filename
urlRemote location.
expected_crc32The expected crc32 value of the file. 0 to ignore.

Definition at line 160 of file IO.cpp.

References WFUT::Encoder::encodeURL().

Referenced by WFUT::WFUTClient::getChannelList(), WFUT::WFUTClient::getFileList(), and WFUT::WFUTClient::getMirrorList().

◆ downloadFile() [2/2]

int WFUT::IO::downloadFile ( FILE *  fp,
const std::string &  url,
uLong  expected_crc32 
)

Tell CURL to immediately download the file in the given URL and save it using the given FILE pointer, optionally checking the CRC32 value. This is a blocking call.

Parameters
fpOpen file descriptor to write file data into.
urlRemote location.
expected_crc32The expected crc32 value of the file. 0 to ignore.

Definition at line 194 of file IO.cpp.

References WFUT::Encoder::encodeURL().

◆ getMaxDownloads()

int WFUT::IO::getMaxDownloads ( ) const
inline

Returns the maximum number of simultaneous downloads allowed.

Definition at line 108 of file IO.h.

◆ init()

int WFUT::IO::init ( )

The init method initialises the CURL backend.

Definition at line 117 of file IO.cpp.

Referenced by WFUT::WFUTClient::init().

◆ poll()

int WFUT::IO::poll ( )

Poll network for data chunks to download and write to disk.

Definition at line 251 of file IO.cpp.

References DownloadComplete, and DownloadFailed.

Referenced by WFUT::WFUTClient::poll().

◆ queueFile()

int WFUT::IO::queueFile ( const std::string &  path,
const std::string &  filename,
const std::string &  url,
uLong  expected_crc32,
bool  executable 
)

Queue a file to be downloaded using the poll function.

See also
IO::poll
Parameters
pathThe directory to save the file into.
filenameThe filename minus the directory.
urlThe full URL of the file
expected_crc32The expected CRC32 value of the file. 0 to ignore.
executableFlag for whether to set the executable flag when ndownloaded.

Definition at line 221 of file IO.cpp.

References WFUT::Encoder::encodeURL().

Referenced by WFUT::WFUTClient::updateChannel(), and WFUT::WFUTClient::updateFile().

◆ setMaxDownloads()

void WFUT::IO::setMaxDownloads ( int  i)
inline

Set the maximum number of simultaneous downloads allowed. Multiple downloads will cause multiple connections to be opened, even if the same remote server is used.

Definition at line 114 of file IO.h.

◆ shutdown()

int WFUT::IO::shutdown ( )

The init method cleans up the CURL backend.

Definition at line 132 of file IO.cpp.

Referenced by WFUT::WFUTClient::shutdown().

Member Data Documentation

◆ DownloadComplete

sigc::signal<void, const std::string&, const std::string&> WFUT::IO::DownloadComplete

The DownloadComplete signal is fired when a file is successfully downloade.

Definition at line 98 of file IO.h.

Referenced by WFUT::WFUTClient::init(), and poll().

◆ DownloadFailed

sigc::signal<void, const std::string&, const std::string&, const std::string&> WFUT::IO::DownloadFailed

The DownloadFailed signal is fired when a file fails to download successfully.

Definition at line 103 of file IO.h.

Referenced by WFUT::WFUTClient::init(), and poll().


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