From 2e71988905041e45f72f71d1d2cab883c53c30e7 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Sun, 12 Nov 2017 23:36:01 +0800 Subject: [PATCH] Sub-folders support for core loading. --- file_io.c | 7 ++++++- file_io.h | 1 + menu.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/file_io.c b/file_io.c index 0710c84..fb0643c 100644 --- a/file_io.c +++ b/file_io.c @@ -571,7 +571,12 @@ int ScanDirectory(char* path, int mode, char *extension, int options) { if(!strlen(path)) continue; } - if (!(options & SCAN_DIR)) continue; + + if (!(options & SCAN_DIR)) + { + if (de->d_name[0] != '_' && strcmp(de->d_name, "..")) continue; + if (!(options & SCAN_SDIR)) continue; + } } else if (de->d_type == DT_REG) { diff --git a/file_io.h b/file_io.h index b68cbfe..c025d99 100644 --- a/file_io.h +++ b/file_io.h @@ -36,6 +36,7 @@ extern int iFirstEntry; // options flags #define SCAN_DIR 1 // include subdirectories #define SCAN_UMOUNT 2 // include subdirectories +#define SCAN_SDIR 4 // include subdirectories void FindStorage(); int getStorage(int from_setting); diff --git a/menu.c b/menu.c index 3fea592..94b39ad 100644 --- a/menu.c +++ b/menu.c @@ -627,7 +627,7 @@ void HandleUI(void) if (get_key_mod() & (LALT|RALT)) //Alt+Menu { OsdSetSize(16); - SelectFile("RBF", 0, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_NONE1, 0); + SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_NONE1, 0); } else if (user_io_core_type() == CORE_TYPE_MINIMIG2) menustate = MENU_MAIN1; @@ -641,7 +641,7 @@ void HandleUI(void) { OsdSetSize(16); OsdCoreNameSet(""); - SelectFile("RBF", 0, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0); + SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0); } else { @@ -3072,7 +3072,7 @@ void HandleUI(void) } else if (select) { if (menusub == 0) { - SelectFile("RBF", 0, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0); + SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0); } else if (menusub == 1) { switch (user_io_core_type()) { @@ -3284,7 +3284,14 @@ void PrintDirectory(void) s[28] = 22; } - strncpy(s + 1, DirItem[k].d_name, len); // display only name + if((DirItem[k].d_type == DT_DIR) && (fs_Options & SCAN_SDIR) && (DirItem[k].d_name[0] == '_')) + { + strncpy(s + 1, DirItem[k].d_name+1, len-1); + } + else + { + strncpy(s + 1, DirItem[k].d_name, len); // display only name + } if (DirItem[k].d_type == DT_DIR) // mark directory with suffix {