MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / downloadFile

Function downloadFile

source/util/networkutils.cpp:81–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81bool downloadFile(BString url, BString filePath, std::function<void(U64 bytesCompleted)> f, NetworkProxy* proxy, BString& errorMsg, bool* cancel) {
82 DownloadProgress progress;
83 progress.cancel = cancel;
84 progress.f = f;
85
86 HRESULT hr = URLDownloadToFile(nullptr, url.c_str(), filePath.c_str(), 0, &progress);
87 if (hr != S_OK) {
88 LPSTR messageBuffer = nullptr;
89 // the use of FORMAT_MESSAGE_ALLOCATE_BUFFER causes this funky cast
90 LPSTR pArg = reinterpret_cast<LPSTR>(&messageBuffer);
91 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), pArg, 0, nullptr);
92 errorMsg = BString::copy(messageBuffer);
93 LocalFree(messageBuffer);
94 }
95 return hr == S_OK;
96}
97
98#else
99#include <curl/curl.h>

Callers 6

updateFileListMethod · 0.85
downloadOpenGLMethod · 0.85
downloadNextFunction · 0.85
ContainersViewMethod · 0.85
DownloadDlgMethod · 0.85
runAppsMethod · 0.85

Calls 1

c_strMethod · 0.45

Tested by

no test coverage detected