From c755d19f58db73ce281b302b744cc468268f3331 Mon Sep 17 00:00:00 2001 From: flb Date: Sat, 27 Mar 2021 01:33:20 +0100 Subject: [PATCH] refactored title id listing code --- .github/workflows/main.yml | 10 +++----- Makefile | 2 +- source/extract.cpp | 49 ++++++++++++++------------------------ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a8c1f90..92f37c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,22 +7,18 @@ on: jobs: AIO-switch-updater: runs-on: ubuntu-latest - container: hamletdufromage/devkita64_devkitarm + #container: hamletdufromage/devkita64_devkitarm + container: devkitpro/devkita64_devkitarm steps: - uses: actions/checkout@v1 - #- name: update libnx - #run: | - #dkp-pacman -Syu --noconfirm - name: update repo run: | git submodule update --init --recursive - name: Building aio-switch-updater run: | - cd aiosu-forwarder - make - cd .. + make -C aiosu-forwarder -f Makefile make -j$(nproc) - uses: actions/upload-artifact@master diff --git a/Makefile b/Makefile index 90ca607..95c707c 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ DATA := data INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann APP_TITLE := All-in-One Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 2.4.3 +APP_VERSION := 2.4.4 TARGET := $(notdir $(CURDIR)) ROMFS := resources diff --git a/source/extract.cpp b/source/extract.cpp index a4bf344..e8a2755 100644 --- a/source/extract.cpp +++ b/source/extract.cpp @@ -111,45 +111,32 @@ void extract(const char * filename, const char* workingPath, const char* toExclu } std::vector getInstalledTitlesNs(){ - Result rc = 0; std::vector titles; - NsApplicationRecord *recs = new NsApplicationRecord[MaxTitleCount](); - NsApplicationControlData *buf=NULL; - u64 outsize = 0; - NacpLanguageEntry *langentry = NULL; - s32 total = 0; - rc = nsListApplicationRecord(recs, MaxTitleCount, 0, &total); - if (R_SUCCEEDED(rc)){ - for (s32 i = 0; i < total; i++){ - outsize = 0; - buf = (NsApplicationControlData*)malloc(sizeof(NsApplicationControlData)); - if (buf == NULL) { - rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory); - } else { - memset(buf, 0, sizeof(NsApplicationControlData)); - } - - if (R_SUCCEEDED(rc)) { - if (R_FAILED(rc)) - printf("nsInitialize() failed: 0x%x\n", rc); - } + NsApplicationRecord *records = new NsApplicationRecord[MaxTitleCount](); + NsApplicationControlData *controlData = NULL; + NacpLanguageEntry* langEntry = NULL; - rc = nsGetApplicationControlData(NsApplicationControlSource_Storage, recs[i].application_id, buf, sizeof(NsApplicationControlData), &outsize); + s32 recordCount = 0; + u64 controlSize = 0; - if (outsize < sizeof(buf->nacp)) - rc = -1; + if (R_SUCCEEDED(nsListApplicationRecord(records, MaxTitleCount, 0, &recordCount))){ + for (s32 i = 0; i < recordCount; i++){ + controlSize = 0; + controlData = (NsApplicationControlData*)malloc(sizeof(NsApplicationControlData)); + if(controlData != NULL) + memset(controlData, 0, sizeof(NsApplicationControlData)); - if (R_SUCCEEDED(rc)) - rc = nacpGetLanguageEntry(&buf->nacp, &langentry); + if(R_FAILED(nsGetApplicationControlData(NsApplicationControlSource_Storage, records[i].application_id, controlData, sizeof(NsApplicationControlData), &controlSize))) continue; - if (R_SUCCEEDED(rc)) { - titles.push_back(util::formatApplicationId(recs[i].application_id)); - } + if(controlSize < sizeof(controlData->nacp)) continue; + + if(R_FAILED(nacpGetLanguageEntry(&controlData->nacp, &langEntry))) continue; + + titles.push_back(util::formatApplicationId(records[i].application_id)); } } - free(buf); - delete[] recs; + delete[] records; std::sort(titles.begin(), titles.end()); return titles; }