mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 10:09:03 +00:00
Refactor DataDownloader and CURLWebClient: update constructor and modify FileExists method signature
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
class DataDownloader {
|
class DataDownloader {
|
||||||
public:
|
public:
|
||||||
/// @brief Initializes global curl state used by this downloader.
|
/// @brief Initializes global curl state used by this downloader.
|
||||||
DataDownloader(std::shared_ptr<IWebClient> webClient);
|
explicit DataDownloader(std::shared_ptr<IWebClient> webClient);
|
||||||
|
|
||||||
/// @brief Cleans up global curl state.
|
/// @brief Cleans up global curl state.
|
||||||
~DataDownloader();
|
~DataDownloader();
|
||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool FileExists(const std::string &filePath) const;
|
static bool FileExists(const std::string &filePath) ;
|
||||||
std::shared_ptr<IWebClient> m_webClient;
|
std::shared_ptr<IWebClient> m_webClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ CurlGlobalState::~CurlGlobalState() { curl_global_cleanup(); }
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// curl write callback that appends response data into a std::string
|
// curl write callback that appends response data into a std::string
|
||||||
static size_t WriteCallbackString(void *contents, size_t size, size_t nmemb,
|
size_t WriteCallbackString(void *contents, size_t size, size_t nmemb,
|
||||||
void *userp) {
|
void *userp) {
|
||||||
size_t realsize = size * nmemb;
|
size_t realsize = size * nmemb;
|
||||||
auto *s = static_cast<std::string *>(userp);
|
auto *s = static_cast<std::string *>(userp);
|
||||||
@@ -26,7 +26,7 @@ static size_t WriteCallbackString(void *contents, size_t size, size_t nmemb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// curl write callback that writes to a file stream
|
// curl write callback that writes to a file stream
|
||||||
static size_t WriteCallbackFile(void *contents, size_t size, size_t nmemb,
|
size_t WriteCallbackFile(void *contents, size_t size, size_t nmemb,
|
||||||
void *userp) {
|
void *userp) {
|
||||||
size_t realsize = size * nmemb;
|
size_t realsize = size * nmemb;
|
||||||
auto *outFile = static_cast<std::ofstream *>(userp);
|
auto *outFile = static_cast<std::ofstream *>(userp);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ DataDownloader::DataDownloader(std::shared_ptr<IWebClient> webClient)
|
|||||||
|
|
||||||
DataDownloader::~DataDownloader() {}
|
DataDownloader::~DataDownloader() {}
|
||||||
|
|
||||||
bool DataDownloader::FileExists(const std::string &filePath) const {
|
bool DataDownloader::FileExists(const std::string &filePath) {
|
||||||
return std::filesystem::exists(filePath);
|
return std::filesystem::exists(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user