diff --git a/source/meme/main.c b/source/meme/main.c index 1fcfceb..7d0f5a7 100644 --- a/source/meme/main.c +++ b/source/meme/main.c @@ -24,11 +24,13 @@ void meme_main(){ sdmmc_storage_set_mmc_partition(&storage, 1); //f_rename("sd:/yeet.txt", "sd:/yote.txt"); - + char *itemsinfolder[250]; unsigned int muhbits[250]; int folderamount = 0; - folderamount = readfolder(itemsinfolder, muhbits); + char path[100] = "sd:/"; + + folderamount = readfolder(itemsinfolder, muhbits, path); int i = 0; gfx_printf("%d", folderamount); diff --git a/source/meme/utils.c b/source/meme/utils.c index 0a49f15..1e795ae 100644 --- a/source/meme/utils.c +++ b/source/meme/utils.c @@ -30,22 +30,22 @@ void utils_waitforpower(){ power_off(); } -int readfolder(char *items[], unsigned int *muhbits){ +int readfolder(char *items[], unsigned int *muhbits, const char path[]){ DIR dir; FILINFO fno; - char path[100] = "sd:/"; + int i = 0; if (f_opendir(&dir, path)) { gfx_printf("\nFailed to open %s", path); } - - int i = 0; - while (!f_readdir(&dir, &fno) && fno.fname[0]){ - size_t size = strlen(fno.fname) + 1; - items[i] = (char*) malloc (size); - strlcpy(items[i], fno.fname, size); - if (fno.fattrib & AM_DIR) muhbits[i] |= (OPTION1); - i++; + else{ + while (!f_readdir(&dir, &fno) && fno.fname[0]){ + size_t size = strlen(fno.fname) + 1; + items[i] = (char*) malloc (size); + strlcpy(items[i], fno.fname, size); + if (fno.fattrib & AM_DIR) muhbits[i] |= (OPTION1); + i++; + } } return i; } \ No newline at end of file diff --git a/source/meme/utils.h b/source/meme/utils.h index fb09b48..1d2565f 100644 --- a/source/meme/utils.h +++ b/source/meme/utils.h @@ -2,4 +2,4 @@ void utils_gfx_init(); void utils_waitforpower(); -int readfolder(char *items[], unsigned int *muhbits); \ No newline at end of file +int readfolder(char *items[], unsigned int *muhbits, const char path[]); \ No newline at end of file