Created
August 23, 2018 15:01
-
-
Save 57op/0bef0d729ab3ffa8f9bda7571cdfa15f to your computer and use it in GitHub Desktop.
nx-listapps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <switch.h> | |
Result initializeServices() { | |
gfxInitDefault(); | |
consoleInit(NULL); | |
Result res; | |
res = ncmInitialize(); | |
if (R_FAILED(res)) { | |
fprintf(stderr, "ncmInitialize failed\n"); | |
return res; | |
} | |
return 0; | |
} | |
int main(int argc, char *argv[]) { | |
Result res = initializeServices(); | |
if (R_FAILED(res)) { | |
ncmExit(); | |
gfxExit(); | |
return res; | |
} | |
NcmContentMetaDatabase *db = malloc(sizeof(*db)); | |
FsStorageId storages[] = { FsStorageId_NandUser, FsStorageId_SdCard, FsStorageId_GameCard }; | |
const char *storages_name[] = { "Nand", "SdCard", "GameCard" }; | |
size_t bufsize = sizeof(NcmApplicationContentMetaKey) * 20; | |
NcmApplicationContentMetaKey *entries = malloc(bufsize); | |
u8 filter = 0x80; // Regular application | |
u32 numEntriesTotal; | |
u32 numEntriesWritten; | |
for (size_t storage_i = 0; storage_i < sizeof(storages) / sizeof(storages[0]); storage_i++) { | |
res = ncmOpenContentMetaDatabase(storages[storage_i], db); | |
if (R_FAILED(res)) { | |
fprintf(stderr, "ncmOpenContentMetaDatabase failed for %s\n", storages_name[storage_i]); | |
continue; | |
} | |
res = ncmContentMetaDatabaseListApplication(db, filter, entries, bufsize, &numEntriesWritten, &numEntriesTotal); | |
if (R_FAILED(res)) { | |
fprintf(stderr, "ncmContentMetaDatabaseListApplication failed for %s\n", storages_name[storage_i]); | |
continue; | |
} | |
for (size_t i = 0; i < numEntriesTotal; i++) { | |
printf("[%016lX, %s]\n", entries[i].metaRecord.titleId, storages_name[storage_i]); | |
} | |
} | |
free(entries); | |
free(db); | |
ncmExit(); | |
printf("\nPress + to exit\n"); | |
while (appletMainLoop()) { | |
hidScanInput(); | |
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); | |
if (kDown & KEY_PLUS) { | |
break; | |
} | |
gfxFlushBuffers(); | |
gfxSwapBuffers(); | |
gfxWaitForVsync(); | |
} | |
gfxExit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment