36 unsigned *HTTPErrorCode =
nullptr);
45 bool downloadToFile(
const std::string &url,
const std::filesystem::path &file,
46 unsigned *HTTPErrorCode =
nullptr);
55 std::optional<std::string>
download(
const std::string &url,
56 unsigned *HTTPErrorCode =
nullptr);
65 unsigned *HTTPErrorCode =
nullptr);
75 const std::filesystem::path &file,
76 unsigned *HTTPErrorCode =
nullptr);
86 static bool isDownloadNeeded(
const std::filesystem::path &filePath,
bool &fileAlreadyExists,
87 bool forceRefresh,
const std::chrono::hours &hours);
99 const std::string &url,
100 bool forceRefresh,
bool ignoreErrors,
101 const std::chrono::hours &hours);
104 static const std::string &
lastError() {
return m_lastError; }
107 static thread_local std::string m_lastError;
static std::optional< std::string > singleDownload(const std::string &url, unsigned *HTTPErrorCode=nullptr)
Download url to a string (and create LibCurl temporarily).
static const std::string & lastError()
Return the last error string if some.
Definition Curl.h:104
LibCurl()
Construct LibCurl.
static std::filesystem::path fetchFileIfNeeded(const std::filesystem::path &filePath, const std::string &url, bool forceRefresh, bool ignoreErrors, const std::chrono::hours &hours)
Fetch url and store into filePath.
bool downloadToFile(const std::string &url, const std::filesystem::path &file, unsigned *HTTPErrorCode=nullptr)
Download url to file.
std::optional< std::string > download(const std::string &url, unsigned *HTTPErrorCode=nullptr)
Download url to a string.
static bool isDownloadNeeded(const std::filesystem::path &filePath, bool &fileAlreadyExists, bool forceRefresh, const std::chrono::hours &hours)
Check if filePath is old enough that it should be downloaded.
bool downloadToStream(const std::string &url, const std::ostream &stream, unsigned *HTTPErrorCode=nullptr)
Download url to stream.
static bool singleDownloadToFile(const std::string &url, const std::filesystem::path &file, unsigned *HTTPErrorCode=nullptr)
Download url to file (and create LibCurl temporarily).