From daff4fb27cf985af4ed84830efe3e4312d4ac9b7 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 30 Jul 2012 00:36:09 +0200 Subject: [PATCH] (PS3/UNIX-type FS) Skips '.' and '..' directories from being included in the dir list when doing dir_list_new --- file_path.c | 3 +++ ps3/frontend/menu.c | 27 +++------------------------ xbox1/frontend/menu.cpp | 9 +-------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/file_path.c b/file_path.c index 9646877c16..60a395df22 100644 --- a/file_path.c +++ b/file_path.c @@ -276,6 +276,9 @@ struct string_list *dir_list_new(const char *dir, const char *ext, bool include_ if (!include_dirs && is_dir) continue; + if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) + continue; + if (!is_dir && ext_list && !string_list_find_elem(ext_list, file_ext)) continue; diff --git a/ps3/frontend/menu.c b/ps3/frontend/menu.c index a2cb0f9234..e2ba9a3e3b 100644 --- a/ps3/frontend/menu.c +++ b/ps3/frontend/menu.c @@ -797,14 +797,7 @@ static void select_file(void) if (input_st & (1 << RETRO_DEVICE_ID_JOYPAD_B)) { if(filebrowser_get_current_path_isdir(&tmpBrowser)) - { - /*if 'filename' is in fact '..' - then pop back directory instead of - adding '..' to filename path */ - if(tmpBrowser.current_dir.ptr == 0) - filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_CANCEL); - else - filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_OK); - } + filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_OK); else if (path_file_exists(filebrowser_get_current_path(&tmpBrowser))) { snprintf(path, sizeof(path), filebrowser_get_current_path(&tmpBrowser)); @@ -916,15 +909,7 @@ static void select_directory(void) else if (input_st & (1 << RETRO_DEVICE_ID_JOYPAD_B)) { if(filebrowser_get_current_path_isdir(&tmpBrowser)) - { - /* if 'filename' is in fact '..' - then pop back directory instead of - * adding '..' to filename path */ - - if(tmpBrowser.current_dir.ptr == 0) - filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_CANCEL); - else - filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_OK); - } + filebrowser_iterate(&tmpBrowser, FILEBROWSER_ACTION_OK); } } @@ -1702,13 +1687,7 @@ static void menu_romselect_iterate(filebrowser_t *filebrowser, menu_romselect_ac { case MENU_ROMSELECT_ACTION_OK: if(filebrowser_get_current_path_isdir(filebrowser)) - { - /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path */ - if(browser.current_dir.ptr == 0) - filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_CANCEL); - else - filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK); - } + filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK); else rarch_console_load_game_wrap(filebrowser_get_current_path(filebrowser), g_console.zip_extract_mode, S_DELAY_45); break; diff --git a/xbox1/frontend/menu.cpp b/xbox1/frontend/menu.cpp index 469df4141a..cadfb005e5 100644 --- a/xbox1/frontend/menu.cpp +++ b/xbox1/frontend/menu.cpp @@ -70,14 +70,7 @@ static void menu_romselect_iterate(filebrowser_t *filebrowser, menu_romselect_ac { case MENU_ROMSELECT_ACTION_OK: if(filebrowser_get_current_path_isdir(filebrowser)) - { - /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path */ - //hacky - need to fix this - //if(browser.current_dir.ptr == 0) - // filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_CANCEL); - //else - filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK); - } + filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK); else rarch_console_load_game_wrap(filebrowser_get_current_path(filebrowser), g_console.zip_extract_mode, S_DELAY_45); break;