mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Add copy & move & more error checks.
This commit is contained in:
@@ -896,7 +896,7 @@ Result ScriptList::runFunctions(nlohmann::json &json) {
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ScriptHelper::removeFile(file, message);
|
||||
if(!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadFile") {
|
||||
@@ -963,8 +963,12 @@ Result ScriptList::runFunctions(nlohmann::json &json) {
|
||||
else missing = true;
|
||||
promptmsg = Lang::get("DELETE_PROMPT") + "\n" + directory;
|
||||
if(!missing) {
|
||||
if (Msg::promptMsg(promptmsg)) {
|
||||
removeDirRecursive(directory.c_str());
|
||||
if(access(directory.c_str(), F_OK) != 0 ) {
|
||||
ret = DELETE_ERROR;
|
||||
} else {
|
||||
if (Msg::promptMsg(promptmsg)) {
|
||||
removeDirRecursive(directory.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else ret = SYNTAX_ERROR;
|
||||
@@ -1021,12 +1025,36 @@ Result ScriptList::runFunctions(nlohmann::json &json) {
|
||||
std::string Message = "";
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
ret = ScriptHelper::prompt(Message);
|
||||
} else if (type == "copy") {
|
||||
std::string Message = "", source = "", destination = "";
|
||||
bool missing = false;
|
||||
if(json.at(choice).at(i).contains("source")) source = json.at(choice).at(i).at("source");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("destination")) destination = json.at(choice).at(i).at("destination");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::copyFile(source, destination, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "move") {
|
||||
std::string Message = "", oldFile = "", newFile = "";
|
||||
bool missing = false;
|
||||
if(json.at(choice).at(i).contains("old")) oldFile = json.at(choice).at(i).at("old");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("new")) newFile = json.at(choice).at(i).at("new");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::renameFile(oldFile, newFile, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == NONE) doneMsg();
|
||||
else if (ret == FAILED_DOWNLOAD) Msg::DisplayWarnMsg(Lang::get("DOWNLOAD_ERROR"));
|
||||
else if (ret == SCRIPT_CANCELED) Msg::DisplayWarnMsg(Lang::get("SCRIPT_CANCELED"));
|
||||
else Msg::DisplayWarnMsg(Lang::get("SYNTAX_ERROR"));
|
||||
else if (ret == SYNTAX_ERROR) Msg::DisplayWarnMsg(Lang::get("SYNTAX_ERROR"));
|
||||
else if (ret == COPY_ERROR) Msg::DisplayWarnMsg(Lang::get("COPY_ERROR"));
|
||||
else if (ret == MOVE_ERROR) Msg::DisplayWarnMsg(Lang::get("MOVE_ERROR"));
|
||||
else if (ret == DELETE_ERROR) Msg::DisplayWarnMsg(Lang::get("DELETE_ERROR"));
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user