mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Add %ARCHIVE_DEFAULT%.
This commit is contained in:
@@ -35,6 +35,7 @@ void Config::addMissingThings() {
|
||||
if (this->json["VERSION"] < 2) {
|
||||
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||
this->setString("NDS_PATH", _NDS_PATH);
|
||||
this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +75,7 @@ void Config::initialize() {
|
||||
this->setBool("SHOW_SPEED", false);
|
||||
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||
this->setString("NDS_PATH", _NDS_PATH);
|
||||
this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT);
|
||||
this->setInt("VERSION", this->configVersion);
|
||||
|
||||
// Write to file.
|
||||
@@ -282,6 +284,12 @@ Config::Config() {
|
||||
this->ndspath(this->getString("NDS_PATH"));
|
||||
}
|
||||
|
||||
if (!this->json.contains("ARCHIVE_PATH")) {
|
||||
this->archivepath(ARCHIVES_DEFAULT);
|
||||
} else {
|
||||
this->archivepath(this->getString("ARCHIVE_PATH"));
|
||||
}
|
||||
|
||||
this->changesMade = false; // No changes made yet.
|
||||
}
|
||||
|
||||
@@ -321,6 +329,8 @@ void Config::save() {
|
||||
this->setBool("SHOW_SPEED", this->showSpeed());
|
||||
this->setString("3DSX_PATH", this->_3dsxpath());
|
||||
this->setString("NDS_PATH", this->ndspath());
|
||||
this->setString("ARCHIVE_PATH", this->archivepath());
|
||||
|
||||
// Write changes to file.
|
||||
const std::string dump = this->json.dump(1, '\t');
|
||||
fwrite(dump.c_str(), 1, this->json.dump(1, '\t').size(), file);
|
||||
|
||||
@@ -71,6 +71,7 @@ Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::st
|
||||
std::string out;
|
||||
out = std::regex_replace(output, std::regex("%3DSX%"), config->_3dsxpath().c_str());
|
||||
out = std::regex_replace(out, std::regex("%NDS%"), config->ndspath().c_str());
|
||||
out = std::regex_replace(out, std::regex("%ARCHIVE_DEFAULT%"), config->archivepath().c_str());
|
||||
|
||||
Result ret = NONE;
|
||||
if (downloadFromRelease("https://github.com/" + repo, file, out, message, includePrereleases, showVersions) != 0) {
|
||||
@@ -89,6 +90,7 @@ Result ScriptHelper::downloadFile(std::string file, std::string output, std::str
|
||||
std::string out;
|
||||
out = std::regex_replace(output, std::regex("%3DSX%"), config->_3dsxpath().c_str());
|
||||
out = std::regex_replace(out, std::regex("%NDS%"), config->ndspath().c_str());
|
||||
out = std::regex_replace(out, std::regex("%ARCHIVE_DEFAULT%"), config->archivepath().c_str());
|
||||
|
||||
Result ret = NONE;
|
||||
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
|
||||
@@ -108,13 +110,16 @@ Result ScriptHelper::downloadFile(std::string file, std::string output, std::str
|
||||
|
||||
// Remove a File.
|
||||
Result ScriptHelper::removeFile(std::string file, std::string message) {
|
||||
std::string out;
|
||||
out = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archivepath().c_str());
|
||||
|
||||
Result ret = NONE;
|
||||
if (access(file.c_str(), F_OK) != 0 ) {
|
||||
if (access(out.c_str(), F_OK) != 0 ) {
|
||||
return DELETE_ERROR;
|
||||
}
|
||||
|
||||
Msg::DisplayMsg(message);
|
||||
deleteFile(file.c_str());
|
||||
deleteFile(out.c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -130,12 +135,16 @@ void ScriptHelper::installFile(std::string file, bool updatingSelf, std::string
|
||||
|
||||
// Extract Files.
|
||||
void ScriptHelper::extractFile(std::string file, std::string input, std::string output, std::string message) {
|
||||
std::string out, in;
|
||||
in = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archivepath().c_str());
|
||||
out = std::regex_replace(output, std::regex("%ARCHIVE_DEFAULT%"), config->archivepath().c_str());
|
||||
|
||||
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
|
||||
showProgressBar = true;
|
||||
filesExtracted = 0;
|
||||
progressbarType = ProgressBar::Extracting;
|
||||
Threads::create((ThreadFunc)displayProgressBar);
|
||||
extractArchive(file, input, output);
|
||||
extractArchive(in, input, out);
|
||||
showProgressBar = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user