/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see .
*/
#include
#include
#include
#include
#include
#include "menu.h"
#include "menu_display.h"
#include "menu_entries.h"
#include "menu_displaylist.h"
#include "menu_navigation.h"
#include "../performance.h"
static void menu_displaylist_push_perfcounter(
menu_displaylist_info_t *info,
const struct retro_perf_counter **counters,
unsigned num, unsigned id)
{
unsigned i;
if (!counters || num == 0)
return;
for (i = 0; i < num; i++)
if (counters[i] && counters[i]->ident)
menu_list_push(info->list,
counters[i]->ident, "", id + i, 0);
}
static int menu_displaylist_push_perfcounter_generic(
menu_displaylist_info_t *info,
const struct retro_perf_counter **counters,
unsigned num, unsigned ident)
{
menu_list_clear(info->list);
menu_displaylist_push_perfcounter(info, counters, num, ident);
menu_driver_populate_entries(
info->path, info->label, info->type);
return 0;
}
/**
* menu_displaylist_parse_drive_list:
* @list : File list handle.
*
* Generates default directory drive list.
* Platform-specific.
*
**/
static void menu_displaylist_parse_drive_list(file_list_t *list)
{
size_t i = 0;
(void)i;
#if defined(GEKKO)
#ifdef HW_RVL
menu_list_push(list,
"sd:/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"usb:/", "", MENU_FILE_DIRECTORY, 0);
#endif
menu_list_push(list,
"carda:/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"cardb:/", "", MENU_FILE_DIRECTORY, 0);
#elif defined(_XBOX1)
menu_list_push(list,
"C:", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"D:", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"E:", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"F:", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"G:", "", MENU_FILE_DIRECTORY, 0);
#elif defined(_XBOX360)
menu_list_push(list,
"game:", "", MENU_FILE_DIRECTORY, 0);
#elif defined(_WIN32)
unsigned drives = GetLogicalDrives();
char drive[] = " :\\";
for (i = 0; i < 32; i++)
{
drive[0] = 'A' + i;
if (drives & (1 << i))
menu_list_push(list,
drive, "", MENU_FILE_DIRECTORY, 0);
}
#elif defined(__CELLOS_LV2__)
menu_list_push(list,
"/app_home/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_hdd0/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_hdd1/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/host_root/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb000/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb001/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb002/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb003/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb004/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb005/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/dev_usb006/", "", MENU_FILE_DIRECTORY, 0);
#elif defined(PSP)
menu_list_push(list,
"ms0:/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"ef0:/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"host0:/", "", MENU_FILE_DIRECTORY, 0);
#elif defined(_3DS)
menu_list_push(list,
"sdmc:/", "", MENU_FILE_DIRECTORY, 0);
#elif defined(IOS)
menu_list_push(list,
"/var/mobile/Documents/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
"/var/mobile/", "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list,
g_defaults.core_dir, "", MENU_FILE_DIRECTORY, 0);
menu_list_push(list, "/", "",
MENU_FILE_DIRECTORY, 0);
#else
menu_list_push(list, "/", "",
MENU_FILE_DIRECTORY, 0);
#endif
}
static int menu_displaylist_parse(
file_list_t *list, file_list_t *menu_list,
const char *dir, const char *label, unsigned type,
unsigned default_type_plain, const char *exts,
rarch_setting_t *setting)
{
size_t i, list_size;
bool path_is_compressed, push_dir;
int device = 0;
struct string_list *str_list = NULL;
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
(void)device;
if (!list || !menu_list)
return -1;
menu_list_clear(list);
if (!*dir)
{
menu_displaylist_parse_drive_list(list);
menu_driver_populate_entries(dir, label, type);
return 0;
}
#if defined(GEKKO) && defined(HW_RVL)
slock_lock(gx_device_mutex);
device = gx_get_device_from_path(dir);
if (device != -1 && !gx_devices[device].mounted &&
gx_devices[device].interface->isInserted())
fatMountSimple(gx_devices[device].name, gx_devices[device].interface);
slock_unlock(gx_device_mutex);
#endif
path_is_compressed = path_is_compressed_file(dir);
push_dir = (setting && setting->browser_selection_type == ST_DIR);
if (path_is_compressed)
str_list = compressed_file_list_new(dir,exts);
else
str_list = dir_list_new(dir,
settings->menu.navigation.browser.filter.supported_extensions_enable
? exts : NULL, true);
if (push_dir)
menu_list_push(list, "