MCPcopy Create free account
hub / github.com/XorTroll/uLaunch / RetrieveToFile

Function RetrieveToFile

projects/uManager/source/ul/man/man_Network.cpp:59–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 void RetrieveToFile(const std::string &url, const std::string &path, RetrieveOnProgressCallback on_progress_cb) {
60 const auto rc = socketInitializeDefault();
61 if(R_FAILED(rc)) {
62 return;
63 }
64
65 auto f = fopen(path.c_str(), "wb");
66 if(f) {
67 g_CurrentOnProgressCallback = on_progress_cb;
68 auto curl = curl_easy_init();
69 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
70 curl_easy_setopt(curl, CURLOPT_USERAGENT, "uManager");
71 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0l);
72 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0l);
73 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1l);
74 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, FileWriteImpl);
75 curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
76 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0l);
77 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, ProgressImpl);
78
79 curl_easy_perform(curl);
80 curl_easy_cleanup(curl);
81 fclose(f);
82 }
83 socketExit();
84 }
85
86 bool HasConnection() {
87 return gethostid() == INADDR_LOOPBACK;

Callers 1

update_DefaultKeyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected