libwfut  0.2.3
Public Member Functions | Public Attributes | List of all members
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.

Member Function Documentation

◆ abortAll()

void WFUT::IO::abortAll ( )

Abort all current and pending downloads.

References abortDownload().

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

◆ abortDownload()

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

Abort the download of the specified file.

Abort all current and pending downloads.

References DownloadFailed.

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

◆ 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.

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.

References WFUT::Encoder::encodeURL().

◆ getMaxDownloads()

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

Returns the maximum number of simultaneous downloads allowed.

◆ init()

int WFUT::IO::init ( )

The init method initialises the CURL backend.

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

◆ poll()

int WFUT::IO::poll ( )

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

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.

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.

References abortAll(), and abortDownload().

◆ shutdown()

int WFUT::IO::shutdown ( )

The init method cleans up the CURL backend.

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.

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.

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


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