A bunch of minor tweaks from cppcheck

This commit is contained in:
Pk11
2021-03-26 06:01:37 -05:00
parent e06d475131
commit c95d66f0e4
19 changed files with 110 additions and 204 deletions
-2
View File
@@ -107,8 +107,6 @@ namespace StoreUtils {
void search(const std::string &query, bool title, bool author, bool category, bool console, int selectedMarks, bool updateAvl, bool isAND);
void FilterUpdateAvailable();
void ResetAll();
void RefreshUpdateAVL();
-1
View File
@@ -56,7 +56,6 @@ struct UniStoreInfo {
bool nameEndsWith(const std::string &name, const std::vector<std::string> &extensionList);
void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<std::string> &extensionList);
void getDirectoryContents(std::vector<DirEntry> &dirContents);
std::vector<std::string> getContents(const std::string &name, const std::vector<std::string> &extensionList);
std::vector<UniStoreInfo> GetUniStoreInfo(const std::string &path);
+12 -12
View File
@@ -54,18 +54,6 @@ enum RequestType {
PROMPT_ERROR = 3 // Error message prompt. Unused right now.
};
class Queue {
public:
Queue(nlohmann::json object, const C2D_Image &img, const std::string &name, const std::string &uName, const std::string &eName, const std::string &lUpdated) :
obj(object), icn(img), name(name), unistoreName(uName), entryName(eName), lastUpdated(lUpdated) { };
QueueStatus status = QueueStatus::None;
nlohmann::json obj;
C2D_Image icn;
int total, current;
std::string name = "", unistoreName = "", entryName = "", lastUpdated = "";
};
/* Of course also a namespace to that part, so we can do that in a Thread. */
namespace QueueSystem {
extern int RequestNeeded, RequestAnswer;
@@ -79,4 +67,16 @@ namespace QueueSystem {
void Resume();
};
class Queue {
public:
Queue(nlohmann::json object, const C2D_Image &img, const std::string &name, const std::string &uName, const std::string &eName, const std::string &lUpdated) :
obj(object), icn(img), total(object.size()), current(QueueSystem::LastElement), name(name), unistoreName(uName), entryName(eName), lastUpdated(lUpdated) { };
QueueStatus status = QueueStatus::None;
nlohmann::json obj;
C2D_Image icn;
int total, current;
std::string name = "", unistoreName = "", entryName = "", lastUpdated = "";
};
#endif
+1 -1
View File
@@ -37,7 +37,7 @@ namespace StringUtils {
std::string formatBytes(int bytes);
std::string GetMarkString(int marks);
std::vector<std::string> GetMarks(int marks);
std::string format(const std::string &fmt_str, ...);
std::string format(const char *fmt_str, ...);
};
#endif
+9 -31
View File
@@ -188,80 +188,58 @@ void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const
}
if (hRepeat & KEY_DOWN) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() < (int)entries.size() - 1) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() + 1);
else StoreUtils::store->SetDownloadIndex(0);
}
if (hRepeat & KEY_UP) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() > 0) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() - 1);
else StoreUtils::store->SetDownloadIndex(entries.size() - 1);
}
if (hRepeat & KEY_RIGHT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() + DOWNLOAD_ENTRIES < (int)entries.size()-1) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() + DOWNLOAD_ENTRIES);
else StoreUtils::store->SetDownloadIndex(entries.size()-1);
}
if (hRepeat & KEY_LEFT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() - DOWNLOAD_ENTRIES > 0) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() - DOWNLOAD_ENTRIES);
else StoreUtils::store->SetDownloadIndex(0);
}
if (smallDelay == 0 && hDown & KEY_TOUCH) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
bool didTouch = false;
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, downloadBoxes[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + StoreUtils::store->GetDownloadSIndex()])) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[i + StoreUtils::store->GetDownloadSIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
didTouch = true;
break;
}
break;
}
}
if (!didTouch) {
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, installedPos[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (installs[i + StoreUtils::store->GetDownloadSIndex()]) {
StoreUtils::meta->RemoveInstalled(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(), entries[i + StoreUtils::store->GetDownloadSIndex()]);
installs[i + StoreUtils::store->GetDownloadSIndex()] = false;
}
if (touching(touch, installedPos[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (installs[i + StoreUtils::store->GetDownloadSIndex()]) {
StoreUtils::meta->RemoveInstalled(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(), entries[i + StoreUtils::store->GetDownloadSIndex()]);
installs[i + StoreUtils::store->GetDownloadSIndex()] = false;
}
didTouch = true;
break;
}
break;
}
}
}
if (smallDelay == 0 && hDown & KEY_A) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[StoreUtils::store->GetDownloadIndex()])) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[StoreUtils::store->GetDownloadIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
}
if (hDown & KEY_X) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (installs[StoreUtils::store->GetDownloadIndex()]) {
StoreUtils::meta->RemoveInstalled(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(), entries[StoreUtils::store->GetDownloadIndex()]);
installs[StoreUtils::store->GetDownloadIndex()] = false;
+5 -5
View File
@@ -47,19 +47,19 @@ static const std::vector<Structs::ButtonPos> markBox = {
void StoreUtils::DisplayMarkBox(int marks) {
Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Darken.
Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ?
Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, ((marks & favoriteMarks::STAR) ?
UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ?
Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, ((marks & favoriteMarks::HEART) ?
UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ?
Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, ((marks & favoriteMarks::DIAMOND) ?
UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ?
Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, ((marks & favoriteMarks::CLUBS) ?
UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ?
Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, ((marks & favoriteMarks::SPADE) ?
UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, UIThemes->TextColor(), "", 0, 0, font);
+5 -5
View File
@@ -90,19 +90,19 @@ void StoreUtils::DrawSearchMenu(const std::vector<bool> &searchIncludes, const s
/* Filters. */
Gui::DrawString(84, SearchMenu[5].y - 20, 0.5f, UIThemes->TextColor(), Lang::get("FILTER_TO"), 265, 0, font);
Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, (marks & favoriteMarks::STAR ?
Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, ((marks & favoriteMarks::STAR) ?
UIThemes->SideBarUnselected() : UIThemes->BoxInside()));
Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ?
Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, ((marks & favoriteMarks::HEART) ?
UIThemes->SideBarUnselected() : UIThemes->BoxInside()));
Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ?
Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, ((marks & favoriteMarks::DIAMOND) ?
UIThemes->SideBarUnselected() : UIThemes->BoxInside()));
Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ?
Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, ((marks & favoriteMarks::CLUBS) ?
UIThemes->SideBarUnselected() : UIThemes->BoxInside()));
Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ?
Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, ((marks & favoriteMarks::SPADE) ?
UIThemes->SideBarUnselected() : UIThemes->BoxInside()));
Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ?
+2 -3
View File
@@ -636,14 +636,13 @@ static void LanguageLogic(int &page, int &selection, int &sPos) {
sPos = 0;
page = 0;
}
break;
}
}
}
if (hDown & KEY_TOUCH) {
if (touching(touch, langButtons[6])) {
/* Download Font. */
std::string l = config->language();
ScriptUtils::downloadFile("https://github.com/Universal-Team/extras/raw/master/files/universal-updater.bcfnt", "sdmc:/3ds/Universal-Updater/font.bcfnt", Lang::get("DOWNLOADING_COMPATIBLE_FONT"), true);
config->customfont(true);
Init::UnloadFont();
+2 -14
View File
@@ -49,7 +49,6 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
int selection = 0, sPos = 0;
std::vector<DirEntry> dirContents;
dirContents.clear();
/* Make sure. */
if (access((oldDir + std::string("/")).c_str(), F_OK) == 0) {
@@ -60,12 +59,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
chdir("sdmc:/");
}
std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp, {"/"});
for(uint i = 0; i < dirContentsTemp.size(); i++) {
dirContents.push_back(dirContentsTemp[i]);
}
getDirectoryContents(dirContents, {"/"});
while(1) {
Gui::clearTextBufs();
@@ -110,13 +104,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
selection = 0;
sPos = 0;
dirContents.clear();
std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp, {"/"});
for(uint i = 0; i < dirContentsTemp.size(); i++) {
dirContents.push_back(dirContentsTemp[i]);
}
getDirectoryContents(dirContents, {"/"});
}
+48 -52
View File
@@ -119,39 +119,37 @@ static bool DownloadStore() {
if (storeJson.is_discarded())
storeJson = { };
if (doSheet) {
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
}
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
@@ -177,39 +175,37 @@ static bool UpdateStore(const std::string &URL) {
if (storeJson.is_discarded())
storeJson = { };
if (doSheet) {
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
}
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
@@ -275,10 +271,10 @@ void Overlays::SelectStore() {
if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected());
Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), info[sPos + i].FileName, 295, 0, font);
}
} else {
GFX::DrawBottom(); // Otherwise we'd draw on top.
}
if (info.size() <= 0) GFX::DrawBottom(); // Otherwise we'd draw on top.
GFX::DrawIcon(sprites_delete_idx, mainButtons[6].x, mainButtons[6].y, UIThemes->TextColor());
GFX::DrawIcon(sprites_update_idx, mainButtons[7].x, mainButtons[7].y, UIThemes->TextColor());
GFX::DrawIcon(sprites_add_idx, mainButtons[8].x, mainButtons[8].y, UIThemes->TextColor());
+4 -6
View File
@@ -50,13 +50,13 @@ MainScreen::MainScreen() {
StoreUtils::meta = std::make_unique<Meta>();
/* Check if lastStore is accessible. */
if (config->lastStore() != "universal-db.unistore" || config->lastStore() != "") {
if (access((std::string(_STORE_PATH) + config->lastStore()).c_str(), F_OK) != 0) {
if (config->lastStore() != "universal-db.unistore" && config->lastStore() != "") {
if (access((_STORE_PATH + config->lastStore()).c_str(), F_OK) != 0) {
config->lastStore("universal-db.unistore");
} else {
/* check version and file here. */
const UniStoreInfo info = GetInfo((std::string(_STORE_PATH) + config->lastStore()), config->lastStore());
const UniStoreInfo info = GetInfo((_STORE_PATH + config->lastStore()), config->lastStore());
if (info.Version != 3 && info.Version != _UNISTORE_VERSION) {
config->lastStore("universal-db.unistore");
@@ -245,10 +245,8 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
this->dwnldList = StoreUtils::store->GetDownloadList(StoreUtils::entries[StoreUtils::store->GetEntry()]->GetEntryIndex());
this->dwnldSizes = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetSizes();
bool good = false;
for (int i = 0; i < (int)this->dwnldList.size(); i++) {
good = false;
bool good = false;
for (int i2 = 0; i2 < (int)installedNames.size(); i2++) {
if (installedNames[i2] == this->dwnldList[i]) {
+3 -13
View File
@@ -140,7 +140,7 @@ void StoreUtils::search(const std::string &query, bool title, bool author, bool
|| (console && findInVector((*it)->GetConsoleFull(), StringUtils::lower_case(query)))
|| (!title && !author && !category && !console))
&& ((selectedMarks == 0 && !updateAvl) || ((((*it)->GetMarks() & selectedMarks) == selectedMarks) && (!updateAvl || (*it)->GetUpdateAvl()))))) {
StoreUtils::entries.erase(it);
it = StoreUtils::entries.erase(it);
--it;
}
}
@@ -153,23 +153,13 @@ void StoreUtils::search(const std::string &query, bool title, bool author, bool
|| (console && findInVector((*it)->GetConsoleFull(), StringUtils::lower_case(query)))
|| (!title && !author && !category && !console))
&& ((selectedMarks == 0 && !updateAvl) || (*it)->GetMarks() & selectedMarks || (updateAvl && (*it)->GetUpdateAvl())))) {
StoreUtils::entries.erase(it);
it = StoreUtils::entries.erase(it);
--it;
}
}
}
}
/* Filter for available updates. */
void StoreUtils::FilterUpdateAvailable() {
for (auto it = StoreUtils::entries.begin(); it != StoreUtils::entries.end(); ++it) {
if (!((*it)->GetUpdateAvl())) {
StoreUtils::entries.erase(it);
--it;
}
}
}
/* Reset everything of the store and clear + fetch the entries again. */
void StoreUtils::ResetAll() {
if (StoreUtils::store) {
@@ -197,7 +187,7 @@ void StoreUtils::RefreshUpdateAVL() {
}
void StoreUtils::AddToQueue(int index, const std::string &entry, const std::string &entryName, const std::string &lUpdated) {
if (!StoreUtils::store && !StoreUtils::store->GetValid()) return;
if (!StoreUtils::store || !StoreUtils::store->GetValid()) return;
/* Check first for proper JSON. */
if (!StoreUtils::store->GetJson().contains("storeContent")) return;
+1 -1
View File
@@ -436,7 +436,7 @@ Result downloadFromRelease(const std::string &url, const std::string &asset, con
@return True if Wi-Fi is connected; false if not.
*/
bool checkWifiStatus(void) {
//return true; // For citra.
// return true; // For citra.
u32 wifiStatus;
bool res = false;
-1
View File
@@ -68,7 +68,6 @@ Result extractArchive(const std::string &archivePath, const std::string &wantedF
archive *a = archive_read_new();
archive_entry *entry;
a = archive_read_new();
archive_read_support_format_all(a);
if (archive_read_open_filename(a, archivePath.c_str(), 0x4000) != ARCHIVE_OK) {
+14 -50
View File
@@ -87,19 +87,6 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents) {
getDirectoryContents(dirContents, {});
}
std::vector<std::string> getContents(const std::string &name, const std::vector<std::string> &extensionList) {
std::vector<std::string> dirContents;
DIR *pdir = opendir(name.c_str());
struct dirent *pent;
while ((pent = readdir(pdir)) != NULL) {
if (nameEndsWith(pent->d_name, extensionList)) dirContents.push_back(pent->d_name);
}
closedir(pdir);
return dirContents;
}
/*
Return UniStore info.
@@ -188,17 +175,20 @@ u32 copyBuf[copyBufSize];
/*
Copy a directory.
DirEntry *entry: Pointer to a DirEntry.
DirEntry &entry: A DirEntry reference.
const char *destinationPath: Pointer to the destination path.
const char *sourcePath: Pointer to the source path.
*/
void dirCopy(DirEntry *entry, const char *destinationPath, const char *sourcePath) {
void dirCopy(const DirEntry &entry, const char *destinationPath, const char *sourcePath) {
std::vector<DirEntry> dirContents;
dirContents.clear();
if (entry->isDirectory) chdir((sourcePath + ("/" + entry->name)).c_str());
if (entry.isDirectory)
chdir((sourcePath + ("/" + entry.name)).c_str());
getDirectoryContents(dirContents);
if (((int)dirContents.size()) == 1) mkdir((destinationPath + ("/" + entry->name)).c_str(), 0777);
if (((int)dirContents.size()) != 1) fcopy((sourcePath + ("/" + entry->name)).c_str(), (destinationPath + ("/" + entry->name)).c_str());
if (((int)dirContents.size()) == 1)
mkdir((destinationPath + ("/" + entry.name)).c_str(), 0777);
if (((int)dirContents.size()) != 1)
fcopy((sourcePath + ("/" + entry.name)).c_str(), (destinationPath + ("/" + entry.name)).c_str());
}
u32 copyOffset = 0, copySize = 0;
@@ -220,13 +210,11 @@ int fcopy(const char *sourcePath, const char *destinationPath) {
chdir(sourcePath);
std::vector<DirEntry> dirContents;
getDirectoryContents(dirContents);
DirEntry *entry = &dirContents.at(1);
mkdir(destinationPath, 0777);
for(int i = 1; i < ((int)dirContents.size()); i++) {
chdir(sourcePath);
entry = &dirContents.at(i);
dirCopy(entry, destinationPath, sourcePath);
dirCopy(dirContents[i], destinationPath, sourcePath);
}
chdir(destinationPath);
@@ -244,51 +232,27 @@ int fcopy(const char *sourcePath, const char *destinationPath) {
fseek(sourceFile, 0, SEEK_END);
copySize = ftell(sourceFile); // Get source file's size.
fseek(sourceFile, 0, SEEK_SET);
} else {
fclose(sourceFile);
return -1;
}
FILE *destinationFile = fopen(destinationPath, "wb");
//if (destinationFile) {
fseek(destinationFile, 0, SEEK_SET);
/*} else {
if (!destinationFile) {
fclose(sourceFile);
fclose(destinationFile);
return -1;
}*/
}
int numr;
while(1) {
scanKeys();
if (keysHeld() & KEY_B) {
/* Cancel copying. */
fclose(sourceFile);
fclose(destinationFile);
return -1;
break;
}
printf("\x1b[16;0H");
printf("Progress:\n");
printf("%i/%i Bytes ", (int)copyOffset, (int)copySize);
/* Copy file to destination path. */
numr = fread(copyBuf, 2, copyBufSize, sourceFile);
fwrite(copyBuf, 2, numr, destinationFile);
copyOffset += copyBufSize;
int numr = fread(copyBuf, sizeof(u32), copyBufSize, sourceFile);
fwrite(copyBuf, sizeof(u32), numr, destinationFile);
copyOffset += copyBufSize * sizeof(u32);
if (copyOffset > copySize) {
fclose(sourceFile);
fclose(destinationFile);
printf("\x1b[17;0H");
printf("%i/%i Bytes ", (int)copyOffset, (int)copySize);
for(int i = 0; i < 30; i++) gspWaitForVBlank();
return 1;
break;
}
}
-3
View File
@@ -105,9 +105,6 @@ void QueueSystem::QueueHandle() {
while(QueueRuns) {
Result ret = NONE; // No Error as of yet.
queueEntries[0]->total = queueEntries[0]->obj.size();
queueEntries[0]->current = QueueSystem::LastElement;
for(int i = QueueSystem::LastElement; ret == NONE && i < queueEntries[0]->total && !QueueSystem::CancelCallback; i++) {
queueEntries[0]->current++;
+1 -1
View File
@@ -32,7 +32,7 @@ C2D_Image Screenshot::Convert(const std::string &filename) {
std::vector<u8> ImageBuffer;
unsigned width, height;
C2D_Image img;
lodepng::decode(ImageBuffer, width, height, filename.c_str());
lodepng::decode(ImageBuffer, width, height, filename);
img.tex = new C3D_Tex;
img.subtex = new Tex3DS_SubTexture({(u16)width, (u16)height, 0.0f, 1.0f, width / 512.0f, 1.0f - (height / 512.0f)});
+2 -2
View File
@@ -107,11 +107,11 @@ std::string StringUtils::GetMarkString(int marks) {
return out;
}
std::string StringUtils::format(const std::string &fmt_str, ...) {
std::string StringUtils::format(const char *fmt_str, ...) {
va_list ap;
char *fp = nullptr;
va_start(ap, fmt_str);
vasprintf(&fp, fmt_str.c_str(), ap);
vasprintf(&fp, fmt_str, ap);
va_end(ap);
std::unique_ptr<char, decltype(free) *> formatted(fp, free);