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

Method extractFile

source/utils/scriptUtils.cpp:277–318  ·  view source on GitHub ↗

Extract files. */

Source from the content-addressed store, hash-verified

275
276/* Extract files. */
277Result 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.

Callers

nothing calls this directly

Calls 7

getExtractedSizeFunction · 0.85
extractArchiveFunction · 0.85
archPathMethod · 0.80
_3dsxPathMethod · 0.80
_3dsxInFolderMethod · 0.80
ndsPathMethod · 0.80
firmPathMethod · 0.80

Tested by

no test coverage detected