Extract files. */
| 275 | |
| 276 | /* Extract files. */ |
| 277 | Result ScriptUtils::extractFile(const std::string &file, const std::string &input, const std::string &output, const std::string &message, bool isARG) { |
| 278 | extractFilesCount = 0; |
| 279 | Result ret = NONE; |
| 280 | |
| 281 | std::string out, in; |
| 282 | in = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archPath()); |
| 283 | in = std::regex_replace(in, std::regex("%3DSX%/(.*)\\.(.*)"), config->_3dsxPath() + (config->_3dsxInFolder() ? "/$1/$1.$2" : "/$1.$2")); |
| 284 | in = std::regex_replace(in, std::regex("%3DSX%"), config->_3dsxPath()); |
| 285 | in = std::regex_replace(in, std::regex("%NDS%"), config->ndsPath()); |
| 286 | in = std::regex_replace(in, std::regex("%FIRM%"), config->firmPath()); |
| 287 | |
| 288 | out = std::regex_replace(output, std::regex("%ARCHIVE_DEFAULT%"), config->archPath()); |
| 289 | out = std::regex_replace(out, std::regex("%3DSX%/(.*)\\.(.*)"), config->_3dsxPath() + (config->_3dsxInFolder() ? "/$1/$1.$2" : "/$1.$2")); |
| 290 | out = std::regex_replace(out, std::regex("%3DSX%"), config->_3dsxPath()); |
| 291 | out = std::regex_replace(out, std::regex("%NDS%"), config->ndsPath()); |
| 292 | out = std::regex_replace(out, std::regex("%FIRM%"), config->firmPath()); |
| 293 | |
| 294 | if (isARG) { |
| 295 | snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str()); |
| 296 | showProgressBar = true; |
| 297 | progressbarType = ProgressBar::Extracting; |
| 298 | |
| 299 | s32 prio = 0; |
| 300 | svcGetThreadPriority(&prio, CUR_THREAD_HANDLE); |
| 301 | thread = threadCreate((ThreadFunc)Animation::displayProgressBar, NULL, 64 * 1024, prio - 1, -2, false); |
| 302 | } |
| 303 | |
| 304 | filesExtracted = 0; |
| 305 | |
| 306 | getExtractedSize(in, input); |
| 307 | if(extractArchive(in, input, out) != EXTRACT_ERROR_NONE) { |
| 308 | ret = EXTRACT_ERROR; |
| 309 | } |
| 310 | |
| 311 | if (isARG) { |
| 312 | showProgressBar = false; |
| 313 | threadJoin(thread, U64_MAX); |
| 314 | threadFree(thread); |
| 315 | } |
| 316 | |
| 317 | return ret; |
| 318 | } |
| 319 | |
| 320 | /* |
| 321 | NOTE: This is for the argument system for now. This might get replaced completely with the Queue System in the future. |
nothing calls this directly
no test coverage detected