#ifndef DOWNLOADER_H #define DOWNLOADER_H #include #include #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #include #define uqdCheckAccess(pathname, mode) _access(pathname, mode) #else #include #include #define uqdCheckAccess(pathname, mode) access(pathname, mode) error_t fopen_s(FILE** f, const char* name, const char* mode); #endif #include #include "DownloaderListener.h" class Downloader { public: Downloader(); Downloader(std::string uqUrl, std::string outputFile, DownloaderListener *downloaderListener = nullptr); ~Downloader(); void setUqUrl(std::string uqUrl); void setOutputFile(std::string outputFile); void setListener(DownloaderListener *downloaderListener); void download(); private: static size_t writefunc(void *curl, size_t size, std::size_t nmemb, std::string *s); static int downloadCallback(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); std::string m_uqUrl, m_outputFile; CURL *m_curl; CURLcode m_res; FILE *m_fp; DownloaderListener *m_downloaderListener = nullptr; }; #endif // DOWNLOADER_H