Download a file. */
| 202 | |
| 203 | /* Download a file. */ |
| 204 | Result 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. */ |
| 249 | void ScriptUtils::installFile(const std::string &file, bool updatingSelf, const std::string &message, bool isARG) { |
nothing calls this directly
no test coverage detected