MCPcopy Create free account
hub / github.com/Universal-Team/Universal-Updater / downloadFile

Method downloadFile

source/utils/scriptUtils.cpp:204–246  ·  view source on GitHub ↗

Download a file. */

Source from the content-addressed store, hash-verified

202
203/* Download a file. */
204Result ScriptUtils::downloadFile(const std::string &file, const std::string &output, const std::string &message, bool isARG) {
205 std::string out;
206 out = std::regex_replace(output, std::regex("%3DSX%/(.*)\\.(.*)"), config->_3dsxPath() + (config->_3dsxInFolder() ? "/$1/$1.$2" : "/$1.$2"));
207 out = std::regex_replace(out, std::regex("%3DSX%"), config->_3dsxPath());
208 out = std::regex_replace(out, std::regex("%NDS%"), config->ndsPath());
209 out = std::regex_replace(out, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
210 out = std::regex_replace(out, std::regex("%FIRM%"), config->firmPath());
211
212 Result ret = NONE;
213
214 if (isARG) {
215 snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
216 showProgressBar = true;
217 progressbarType = ProgressBar::Downloading;
218
219 s32 prio = 0;
220 svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
221 thread = threadCreate((ThreadFunc)Animation::displayProgressBar, NULL, 64 * 1024, prio - 1, -2, false);
222 }
223
224 if (downloadToFile(file, out) != 0) {
225 ret = FAILED_DOWNLOAD;
226
227 if (isARG) {
228 showProgressBar = false;
229
230 downloadFailed();
231
232 threadJoin(thread, U64_MAX);
233 threadFree(thread);
234 }
235
236 return ret;
237 }
238
239 if (isARG) {
240 showProgressBar = false;
241 threadJoin(thread, U64_MAX);
242 threadFree(thread);
243 }
244
245 return ret;
246}
247
248/* Install CIA files. */
249void ScriptUtils::installFile(const std::string &file, bool updatingSelf, const std::string &message, bool isARG) {

Callers

nothing calls this directly

Calls 7

downloadToFileFunction · 0.85
downloadFailedFunction · 0.85
_3dsxPathMethod · 0.80
_3dsxInFolderMethod · 0.80
ndsPathMethod · 0.80
archPathMethod · 0.80
firmPathMethod · 0.80

Tested by

no test coverage detected