wfut
0.2.4
A client side C++ implementation of WFUT (WorldForge Update Tool).
|
#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 |
The IO class wraps most of the CURL related calls, taking a URL to a file and writing it to a local file.
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(), and setMaxDownloads().
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.
References DownloadFailed.
Referenced by abortAll(), WFUT::WFUTClient::abortDownload(), and setMaxDownloads().
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.
filename | Destination filename |
url | Remote location. |
expected_crc32 | The 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().
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.
fp | Open file descriptor to write file data into. |
url | Remote location. |
expected_crc32 | The expected crc32 value of the file. 0 to ignore. |
Definition at line 194 of file IO.cpp.
References WFUT::Encoder::encodeURL().
|
inline |
int WFUT::IO::init | ( | ) |
The init method initialises the CURL backend.
Definition at line 117 of file IO.cpp.
Referenced by WFUT::WFUTClient::init().
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().
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.
path | The directory to save the file into. |
filename | The filename minus the directory. |
url | The full URL of the file |
expected_crc32 | The expected CRC32 value of the file. 0 to ignore. |
executable | Flag 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().
|
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.
References abortAll(), and abortDownload().
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().
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().
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 abortDownload(), WFUT::WFUTClient::init(), and poll().