mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-07 08:49:08 +00:00
I do not like if(..).
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
#define APP_TITLE "Universal-Updater"
|
#define APP_TITLE "Universal-Updater"
|
||||||
#define VERSION_STRING "2.3.0"
|
#define VERSION_STRING "2.4.0"
|
||||||
|
|
||||||
// The Release Fetch struct.
|
// The Release Fetch struct.
|
||||||
struct ReleaseFetch {
|
struct ReleaseFetch {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#ifndef SOUND_H
|
||||||
|
#define SOUND_H
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class sound
|
class sound {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
sound(const std::string& path, int channel = 1, bool toloop = true);
|
sound(const std::string& path, int channel = 1, bool toloop = true);
|
||||||
~sound();
|
~sound();
|
||||||
@@ -17,3 +17,5 @@ private:
|
|||||||
u8* data = NULL;
|
u8* data = NULL;
|
||||||
int chnl;
|
int chnl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -72,8 +72,7 @@ void Animation::DrawProgressBarExtract(u64 currentProgress, u64 totalProgress, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::Button(int x, int y, float speed)
|
void Animation::Button(int x, int y, float speed) {
|
||||||
{
|
|
||||||
static float timer = 0.0f;
|
static float timer = 0.0f;
|
||||||
float highlight_multiplier = fmax(0.0, fabs(fmod(timer, 1.0) - 0.5) / 0.5);
|
float highlight_multiplier = fmax(0.0, fabs(fmod(timer, 1.0) - 0.5) / 0.5);
|
||||||
u8 r, g, b;
|
u8 r, g, b;
|
||||||
|
|||||||
@@ -257,31 +257,27 @@ static size_t handle_data(char* ptr, size_t size, size_t nmemb, void* userdata)
|
|||||||
(void) userdata;
|
(void) userdata;
|
||||||
const size_t bsz = size*nmemb;
|
const size_t bsz = size*nmemb;
|
||||||
|
|
||||||
if (result_sz == 0 || !result_buf)
|
if (result_sz == 0 || !result_buf) {
|
||||||
{
|
|
||||||
result_sz = 0x1000;
|
result_sz = 0x1000;
|
||||||
result_buf = (char*)malloc(result_sz);
|
result_buf = (char*)malloc(result_sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool need_realloc = false;
|
bool need_realloc = false;
|
||||||
while (result_written + bsz > result_sz)
|
while (result_written + bsz > result_sz) {
|
||||||
{
|
|
||||||
result_sz <<= 1;
|
result_sz <<= 1;
|
||||||
need_realloc = true;
|
need_realloc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_realloc)
|
if (need_realloc) {
|
||||||
{
|
|
||||||
char *new_buf = (char*)realloc(result_buf, result_sz);
|
char *new_buf = (char*)realloc(result_buf, result_sz);
|
||||||
if (!new_buf)
|
if (!new_buf) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_buf = new_buf;
|
result_buf = new_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result_buf)
|
if (!result_buf) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,12 +322,13 @@ std::vector<ReleaseFetch> fetchReleases(nlohmann::json API) {
|
|||||||
// Push to the Vector.
|
// Push to the Vector.
|
||||||
fetchVector.push_back(fetch[i]);
|
fetchVector.push_back(fetch[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetchVector;
|
return fetchVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern touchPosition touch;
|
extern touchPosition touch;
|
||||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||||
std::vector<Structs::ButtonPos> arrowPos = {
|
const std::vector<Structs::ButtonPos> arrowPos = {
|
||||||
{295, 0, 25, 25}, // Arrow Up.
|
{295, 0, 25, 25}, // Arrow Up.
|
||||||
{295, 215, 25, 25} // Arrow Down.
|
{295, 215, 25, 25} // Arrow Down.
|
||||||
};
|
};
|
||||||
@@ -381,6 +378,7 @@ int SelectRelease(std::vector<ReleaseFetch> bruh) {
|
|||||||
if (screenPos + i == selectedRelease) {
|
if (screenPos + i == selectedRelease) {
|
||||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, selected);
|
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, TextColor, line1, 320);
|
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, TextColor, line1, 320);
|
||||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, TextColor, line2, 320);
|
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, TextColor, line2, 320);
|
||||||
}
|
}
|
||||||
@@ -391,6 +389,7 @@ int SelectRelease(std::vector<ReleaseFetch> bruh) {
|
|||||||
if (screenPosList + i == selectedRelease) {
|
if (screenPosList + i == selectedRelease) {
|
||||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, selected);
|
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, TextColor, line1, 320);
|
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, TextColor, line1, 320);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -504,14 +503,12 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *socubuf = memalign(0x1000, 0x100000);
|
void *socubuf = memalign(0x1000, 0x100000);
|
||||||
if (!socubuf)
|
if (!socubuf) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = socInit((u32*)socubuf, 0x100000);
|
ret = socInit((u32*)socubuf, 0x100000);
|
||||||
if (R_FAILED(ret))
|
if (R_FAILED(ret)) {
|
||||||
{
|
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -576,6 +573,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path,
|
|||||||
// All were prereleases and those are being ignored
|
// All were prereleases and those are being ignored
|
||||||
return -2; // TODO: Maybe change this? I'm note sure what good return values are -Pk11
|
return -2; // TODO: Maybe change this? I'm note sure what good return values are -Pk11
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ReleaseFetch> fetchResult = fetchReleases(parsedAPI);
|
std::vector<ReleaseFetch> fetchResult = fetchReleases(parsedAPI);
|
||||||
int release = SelectRelease(fetchResult);
|
int release = SelectRelease(fetchResult);
|
||||||
|
|
||||||
@@ -593,6 +591,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path,
|
|||||||
} else if (includePrereleases) {
|
} else if (includePrereleases) {
|
||||||
parsedAPI = parsedAPI[0];
|
parsedAPI = parsedAPI[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedAPI["assets"].is_array()) {
|
if (parsedAPI["assets"].is_array()) {
|
||||||
for (auto jsonAsset : parsedAPI["assets"]) {
|
for (auto jsonAsset : parsedAPI["assets"]) {
|
||||||
if (jsonAsset.is_object() && jsonAsset["name"].is_string() && jsonAsset["browser_download_url"].is_string()) {
|
if (jsonAsset.is_object() && jsonAsset["name"].is_string() && jsonAsset["browser_download_url"].is_string()) {
|
||||||
@@ -619,6 +618,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path,
|
|||||||
Threads::create((ThreadFunc)displayProgressBar);
|
Threads::create((ThreadFunc)displayProgressBar);
|
||||||
ret = downloadToFile(assetUrl, path);
|
ret = downloadToFile(assetUrl, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,18 +653,15 @@ void notConnectedMsg(void) {
|
|||||||
Msg::DisplayWarnMsg(Lang::get("CONNECT_WIFI"));
|
Msg::DisplayWarnMsg(Lang::get("CONNECT_WIFI"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getLatestRelease(std::string repo, std::string item)
|
std::string getLatestRelease(std::string repo, std::string item) {
|
||||||
{
|
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
void *socubuf = memalign(0x1000, 0x100000);
|
void *socubuf = memalign(0x1000, 0x100000);
|
||||||
if (!socubuf)
|
if (!socubuf) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = socInit((u32*)socubuf, 0x100000);
|
ret = socInit((u32*)socubuf, 0x100000);
|
||||||
if (R_FAILED(ret))
|
if (R_FAILED(ret)) {
|
||||||
{
|
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -707,6 +704,7 @@ std::string getLatestRelease(std::string repo, std::string item)
|
|||||||
if (parsedAPI[item].is_string()) {
|
if (parsedAPI[item].is_string()) {
|
||||||
jsonItem = parsedAPI[item];
|
jsonItem = parsedAPI[item];
|
||||||
}
|
}
|
||||||
|
|
||||||
socExit();
|
socExit();
|
||||||
free(result_buf);
|
free(result_buf);
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
@@ -720,14 +718,12 @@ std::string getLatestRelease(std::string repo, std::string item)
|
|||||||
std::string getLatestCommit(std::string repo, std::string item) {
|
std::string getLatestCommit(std::string repo, std::string item) {
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
void *socubuf = memalign(0x1000, 0x100000);
|
void *socubuf = memalign(0x1000, 0x100000);
|
||||||
if (!socubuf)
|
if (!socubuf) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = socInit((u32*)socubuf, 0x100000);
|
ret = socInit((u32*)socubuf, 0x100000);
|
||||||
if (R_FAILED(ret))
|
if (R_FAILED(ret)) {
|
||||||
{
|
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -770,6 +766,7 @@ std::string getLatestCommit(std::string repo, std::string item) {
|
|||||||
if (parsedAPI[item].is_string()) {
|
if (parsedAPI[item].is_string()) {
|
||||||
jsonItem = parsedAPI[item];
|
jsonItem = parsedAPI[item];
|
||||||
}
|
}
|
||||||
|
|
||||||
socExit();
|
socExit();
|
||||||
free(result_buf);
|
free(result_buf);
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
@@ -783,14 +780,12 @@ std::string getLatestCommit(std::string repo, std::string item) {
|
|||||||
std::string getLatestCommit(std::string repo, std::string array, std::string item) {
|
std::string getLatestCommit(std::string repo, std::string array, std::string item) {
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
void *socubuf = memalign(0x1000, 0x100000);
|
void *socubuf = memalign(0x1000, 0x100000);
|
||||||
if (!socubuf)
|
if (!socubuf) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = socInit((u32*)socubuf, 0x100000);
|
ret = socInit((u32*)socubuf, 0x100000);
|
||||||
if (R_FAILED(ret))
|
if (R_FAILED(ret)) {
|
||||||
{
|
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -833,6 +828,7 @@ std::string getLatestCommit(std::string repo, std::string array, std::string ite
|
|||||||
if (parsedAPI[array][item].is_string()) {
|
if (parsedAPI[array][item].is_string()) {
|
||||||
jsonItem = parsedAPI[array][item];
|
jsonItem = parsedAPI[array][item];
|
||||||
}
|
}
|
||||||
|
|
||||||
socExit();
|
socExit();
|
||||||
free(result_buf);
|
free(result_buf);
|
||||||
free(socubuf);
|
free(socubuf);
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ Structs::ButtonPos Numbers [] = {
|
|||||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||||
|
|
||||||
|
|
||||||
void Input::DrawNumpad()
|
void Input::DrawNumpad() {
|
||||||
{
|
|
||||||
for(uint i=0;i<(sizeof(NumpadStruct)/sizeof(NumpadStruct[0]));i++) {
|
for(uint i=0;i<(sizeof(NumpadStruct)/sizeof(NumpadStruct[0]));i++) {
|
||||||
Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, Config::Color1);
|
Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, Config::Color1);
|
||||||
char c[2] = {NumpadStruct[i].character[0]};
|
char c[2] = {NumpadStruct[i].character[0]};
|
||||||
@@ -98,6 +97,7 @@ void Input::drawKeyboard() {
|
|||||||
Gui::DrawString(keysQWERTY[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTY[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, Config::TxtColor, c);
|
Gui::DrawString(keysQWERTY[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTY[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, Config::TxtColor, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint i=0;i<(sizeof(modifierKeys)/sizeof(modifierKeys[0]));i++) {
|
for(uint i=0;i<(sizeof(modifierKeys)/sizeof(modifierKeys[0]));i++) {
|
||||||
std::string enter = modifierKeys[2].character;
|
std::string enter = modifierKeys[2].character;
|
||||||
std::string arrowUp = modifierKeys[3].character;
|
std::string arrowUp = modifierKeys[3].character;
|
||||||
@@ -116,8 +116,7 @@ void Input::drawKeyboard() {
|
|||||||
|
|
||||||
std::string Input::Numpad(std::string Text) { return Input::Numpad(-1, Text); }
|
std::string Input::Numpad(std::string Text) { return Input::Numpad(-1, Text); }
|
||||||
|
|
||||||
std::string Input::Numpad(uint maxLength, std::string Text)
|
std::string Input::Numpad(uint maxLength, std::string Text) {
|
||||||
{
|
|
||||||
int hDown;
|
int hDown;
|
||||||
touchPosition touch;
|
touchPosition touch;
|
||||||
std::string string;
|
std::string string;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ void Msg::DisplayMsg(std::string text) {
|
|||||||
} else if (isScriptSelected == true) {
|
} else if (isScriptSelected == true) {
|
||||||
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, TextColor, text, 395, 70);
|
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, TextColor, text, 395, 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX::DrawBottom();
|
GFX::DrawBottom();
|
||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,7 @@ void Msg::DisplayWarnMsg(std::string Text) {
|
|||||||
} else if (isScriptSelected == true) {
|
} else if (isScriptSelected == true) {
|
||||||
Gui::DrawStringCentered(0, 1, 0.6f, TextColor, Text, 400);
|
Gui::DrawStringCentered(0, 1, 0.6f, TextColor, Text, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX::DrawBottom();
|
GFX::DrawBottom();
|
||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
for (int i = 0; i < 60*3; i++) {
|
for (int i = 0; i < 60*3; i++) {
|
||||||
|
|||||||
+3
-5
@@ -30,8 +30,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
std::string Logging::format(const std::string& fmt_str, ...)
|
std::string Logging::format(const std::string& fmt_str, ...) {
|
||||||
{
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char* fp = NULL;
|
char* fp = NULL;
|
||||||
va_start(ap, fmt_str);
|
va_start(ap, fmt_str);
|
||||||
@@ -41,8 +40,7 @@ std::string Logging::format(const std::string& fmt_str, ...)
|
|||||||
return std::string(formatted.get());
|
return std::string(formatted.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Logging::logDate(void)
|
std::string Logging::logDate(void) {
|
||||||
{
|
|
||||||
time_t unixTime;
|
time_t unixTime;
|
||||||
struct tm timeStruct;
|
struct tm timeStruct;
|
||||||
time(&unixTime);
|
time(&unixTime);
|
||||||
@@ -59,7 +57,7 @@ void Logging::createLogFile(void) {
|
|||||||
|
|
||||||
// Only write to the Log, if it is enabled in the Settings File!
|
// Only write to the Log, if it is enabled in the Settings File!
|
||||||
void Logging::writeToLog(std::string debugText) {
|
void Logging::writeToLog(std::string debugText) {
|
||||||
if (Config::getBool("LOGGING") == true) {
|
if (Config::getBool("LOGGING")) {
|
||||||
std::ofstream logFile;
|
std::ofstream logFile;
|
||||||
logFile.open(("sdmc:/3ds/Universal-Updater/Log.log"), std::ofstream::app);
|
logFile.open(("sdmc:/3ds/Universal-Updater/Log.log"), std::ofstream::app);
|
||||||
std::string writeDebug = "[ ";
|
std::string writeDebug = "[ ";
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result deletePrevious(u64 titleid, FS_MediaType media)
|
Result deletePrevious(u64 titleid, FS_MediaType media) {
|
||||||
{
|
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
|
|
||||||
u32 titles_amount = 0;
|
u32 titles_amount = 0;
|
||||||
@@ -65,8 +64,7 @@ FS_MediaType getTitleDestination(u64 titleId) {
|
|||||||
// Variables.
|
// Variables.
|
||||||
u64 installSize = 0, installOffset = 0;
|
u64 installSize = 0, installOffset = 0;
|
||||||
|
|
||||||
Result installCia(const char * ciaPath, bool updatingSelf)
|
Result installCia(const char * ciaPath, bool updatingSelf) {
|
||||||
{
|
|
||||||
u32 bytes_read = 0, bytes_written;
|
u32 bytes_read = 0, bytes_written;
|
||||||
installSize = 0, installOffset = 0; u64 size = 0;
|
installSize = 0, installOffset = 0; u64 size = 0;
|
||||||
Handle ciaHandle, fileHandle;
|
Handle ciaHandle, fileHandle;
|
||||||
@@ -124,6 +122,7 @@ Result installCia(const char * ciaPath, bool updatingSelf)
|
|||||||
printf("Error in:\nAM_FinishCiaInstall\n");
|
printf("Error in:\nAM_FinishCiaInstall\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FSFILE_Close(fileHandle);
|
ret = FSFILE_Close(fileHandle);
|
||||||
if (R_FAILED(ret)) {
|
if (R_FAILED(ret)) {
|
||||||
printf("Error in:\nFSFILE_Close\n");
|
printf("Error in:\nFSFILE_Close\n");
|
||||||
@@ -131,8 +130,8 @@ Result installCia(const char * ciaPath, bool updatingSelf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updatingSelf) {
|
if (updatingSelf) {
|
||||||
if (R_FAILED(ret = CIA_LaunchTitle(info.titleID, MEDIATYPE_SD)))
|
if (R_FAILED(ret = CIA_LaunchTitle(info.titleID, MEDIATYPE_SD))) return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -91,6 +91,7 @@ Result extractArchive(std::string archivePath, std::string wantedFile, std::stri
|
|||||||
sizeLeft -= size;
|
sizeLeft -= size;
|
||||||
writeOffset += size;
|
writeOffset += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
filesExtracted++;
|
filesExtracted++;
|
||||||
fclose(file);
|
fclose(file);
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::st
|
|||||||
ret = FAILED_DOWNLOAD;
|
ret = FAILED_DOWNLOAD;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
showProgressBar = false;
|
showProgressBar = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -90,6 +91,7 @@ Result ScriptHelper::downloadFile(std::string file, std::string output, std::str
|
|||||||
ret = FAILED_DOWNLOAD;
|
ret = FAILED_DOWNLOAD;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
showProgressBar = false;
|
showProgressBar = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -100,6 +102,7 @@ Result ScriptHelper::removeFile(std::string file, std::string message) {
|
|||||||
if (access(file.c_str(), F_OK) != 0 ) {
|
if (access(file.c_str(), F_OK) != 0 ) {
|
||||||
return DELETE_ERROR;
|
return DELETE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::DisplayMsg(message);
|
Msg::DisplayMsg(message);
|
||||||
deleteFile(file.c_str());
|
deleteFile(file.c_str());
|
||||||
return ret;
|
return ret;
|
||||||
@@ -148,6 +151,7 @@ bool ScriptHelper::checkIfValid(std::string scriptFile, int mode) {
|
|||||||
printf("File not found\n");
|
printf("File not found\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@@ -181,6 +185,7 @@ Result ScriptHelper::prompt(std::string message) {
|
|||||||
if (!Msg::promptMsg(message)) {
|
if (!Msg::promptMsg(message)) {
|
||||||
ret = SCRIPT_CANCELED;
|
ret = SCRIPT_CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,11 +194,13 @@ Result ScriptHelper::copyFile(std::string source, std::string destination, std::
|
|||||||
if (access(source.c_str(), F_OK) != 0 ) {
|
if (access(source.c_str(), F_OK) != 0 ) {
|
||||||
return COPY_ERROR;
|
return COPY_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::DisplayMsg(message);
|
Msg::DisplayMsg(message);
|
||||||
// If destination does not exist, create dirs.
|
// If destination does not exist, create dirs.
|
||||||
if (access(destination.c_str(), F_OK) != 0 ) {
|
if (access(destination.c_str(), F_OK) != 0 ) {
|
||||||
makeDirs(destination.c_str());
|
makeDirs(destination.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
fcopy(source.c_str(), destination.c_str());
|
fcopy(source.c_str(), destination.c_str());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -203,6 +210,7 @@ Result ScriptHelper::renameFile(std::string oldName, std::string newName, std::s
|
|||||||
if (access(oldName.c_str(), F_OK) != 0 ) {
|
if (access(oldName.c_str(), F_OK) != 0 ) {
|
||||||
return MOVE_ERROR;
|
return MOVE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::DisplayMsg(message);
|
Msg::DisplayMsg(message);
|
||||||
// TODO: Kinda avoid that?
|
// TODO: Kinda avoid that?
|
||||||
makeDirs(newName.c_str());
|
makeDirs(newName.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user