2015-10-26 07:39:35 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2016-03-20 16:28:24 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 03:06:50 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2016-10-27 15:47:10 +00:00
|
|
|
* Copyright (C) 2016 - Brad Parker
|
2015-10-26 07:39:35 +00:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2016-03-20 16:28:24 +00:00
|
|
|
#include <lists/dir_list.h>
|
2016-07-18 05:05:47 +00:00
|
|
|
#include <lists/string_list.h>
|
2016-04-10 20:00:50 +00:00
|
|
|
#include <compat/strl.h>
|
2016-03-20 16:28:24 +00:00
|
|
|
|
2016-09-06 21:52:33 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 07:39:35 +00:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "menu/menu_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 07:42:34 +00:00
|
|
|
#ifdef HAVE_CAMERA
|
|
|
|
#include "camera/camera_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2016-09-21 14:06:14 +00:00
|
|
|
#ifdef HAVE_WIFI
|
|
|
|
#include "wifi/wifi_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 17:33:39 +00:00
|
|
|
#ifdef HAVE_LOCATION
|
|
|
|
#include "location/location_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2016-09-08 03:48:43 +00:00
|
|
|
#include "list_special.h"
|
|
|
|
#include "frontend/frontend_driver.h"
|
2015-12-11 12:56:00 +00:00
|
|
|
#include "core_info.h"
|
2015-10-26 07:59:23 +00:00
|
|
|
#include "gfx/video_driver.h"
|
|
|
|
#include "input/input_driver.h"
|
2015-10-26 17:41:13 +00:00
|
|
|
#include "input/input_hid_driver.h"
|
2015-10-26 08:06:11 +00:00
|
|
|
#include "input/input_joypad_driver.h"
|
2015-10-26 07:52:25 +00:00
|
|
|
#include "audio/audio_driver.h"
|
2015-10-26 17:41:13 +00:00
|
|
|
#include "audio/audio_resampler_driver.h"
|
2015-10-26 17:33:39 +00:00
|
|
|
#include "record/record_driver.h"
|
2016-08-28 01:48:55 +00:00
|
|
|
#include "configuration.h"
|
2015-10-26 07:52:25 +00:00
|
|
|
|
2016-03-20 16:28:24 +00:00
|
|
|
struct string_list *dir_list_new_special(const char *input_dir,
|
|
|
|
enum dir_list_type type, const char *filter)
|
|
|
|
{
|
2016-10-27 07:44:20 +00:00
|
|
|
char ext_shaders[255];
|
|
|
|
char ext_name[255];
|
2016-07-18 05:11:08 +00:00
|
|
|
const char *dir = NULL;
|
|
|
|
const char *exts = NULL;
|
|
|
|
bool include_dirs = false;
|
2016-08-21 04:59:41 +00:00
|
|
|
bool recursive = false;
|
2016-08-28 01:48:55 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-03-20 16:28:24 +00:00
|
|
|
|
2016-10-21 03:57:40 +00:00
|
|
|
ext_shaders[0] = ext_name[0] = '\0';
|
|
|
|
|
2016-03-20 16:28:24 +00:00
|
|
|
(void)input_dir;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2016-05-21 11:31:41 +00:00
|
|
|
case DIR_LIST_AUTOCONFIG:
|
|
|
|
dir = input_dir;
|
|
|
|
exts = filter;
|
|
|
|
break;
|
2016-03-20 16:28:24 +00:00
|
|
|
case DIR_LIST_CORES:
|
2016-07-18 05:15:58 +00:00
|
|
|
dir = input_dir;
|
2016-03-20 16:28:24 +00:00
|
|
|
|
|
|
|
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
exts = ext_name;
|
|
|
|
break;
|
|
|
|
case DIR_LIST_CORE_INFO:
|
|
|
|
{
|
|
|
|
core_info_list_t *list = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
core_info_get_list(&list);
|
2016-03-20 16:28:24 +00:00
|
|
|
|
|
|
|
dir = input_dir;
|
|
|
|
exts = list->all_ext;
|
|
|
|
}
|
|
|
|
break;
|
2016-08-21 04:59:41 +00:00
|
|
|
case DIR_LIST_RECURSIVE:
|
|
|
|
{
|
|
|
|
core_info_list_t *list = NULL;
|
|
|
|
core_info_get_list(&list);
|
|
|
|
|
|
|
|
dir = input_dir;
|
|
|
|
exts = list->all_ext;
|
|
|
|
recursive = true;
|
|
|
|
}
|
|
|
|
break;
|
2016-03-20 16:28:24 +00:00
|
|
|
case DIR_LIST_SHADERS:
|
2016-07-18 05:05:47 +00:00
|
|
|
{
|
|
|
|
union string_list_elem_attr attr = {0};
|
|
|
|
struct string_list *str_list = string_list_new();
|
|
|
|
|
|
|
|
if (!str_list)
|
|
|
|
return NULL;
|
|
|
|
|
2016-07-24 09:32:45 +00:00
|
|
|
(void)attr;
|
|
|
|
|
2016-07-18 05:11:08 +00:00
|
|
|
dir = input_dir;
|
2016-04-10 20:00:50 +00:00
|
|
|
#ifdef HAVE_CG
|
2016-07-18 05:05:47 +00:00
|
|
|
string_list_append(str_list, "cg", attr);
|
|
|
|
string_list_append(str_list, "cgp", attr);
|
2016-04-10 20:00:50 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GLSL
|
2016-07-18 05:05:47 +00:00
|
|
|
string_list_append(str_list, "glsl", attr);
|
|
|
|
string_list_append(str_list, "glslp", attr);
|
2016-04-10 20:00:50 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VULKAN
|
2016-07-18 05:05:47 +00:00
|
|
|
string_list_append(str_list, "slang", attr);
|
|
|
|
string_list_append(str_list, "slangp", attr);
|
2016-04-10 20:00:50 +00:00
|
|
|
#endif
|
2016-07-18 05:05:47 +00:00
|
|
|
string_list_join_concat(ext_shaders, sizeof(ext_shaders), str_list, "|");
|
|
|
|
string_list_free(str_list);
|
|
|
|
exts = ext_shaders;
|
|
|
|
}
|
2016-03-20 16:28:24 +00:00
|
|
|
break;
|
|
|
|
case DIR_LIST_COLLECTIONS:
|
2016-07-18 05:15:58 +00:00
|
|
|
dir = input_dir;
|
2016-03-20 16:28:24 +00:00
|
|
|
exts = "lpl";
|
|
|
|
break;
|
|
|
|
case DIR_LIST_DATABASES:
|
2016-07-18 05:15:58 +00:00
|
|
|
dir = input_dir;
|
2016-03-20 16:28:24 +00:00
|
|
|
exts = "rdb";
|
|
|
|
break;
|
|
|
|
case DIR_LIST_PLAIN:
|
|
|
|
dir = input_dir;
|
|
|
|
exts = filter;
|
|
|
|
break;
|
|
|
|
case DIR_LIST_NONE:
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-08-28 01:48:55 +00:00
|
|
|
return dir_list_new(dir, exts, include_dirs, settings->show_hidden_files, type == DIR_LIST_CORE_INFO, recursive);
|
2016-03-20 16:28:24 +00:00
|
|
|
}
|
|
|
|
|
2015-10-26 18:41:20 +00:00
|
|
|
struct string_list *string_list_new_special(enum string_list_type type,
|
2015-10-26 20:03:28 +00:00
|
|
|
void *data, unsigned *len, size_t *list_size)
|
2015-10-26 07:39:35 +00:00
|
|
|
{
|
|
|
|
union string_list_elem_attr attr;
|
|
|
|
unsigned i;
|
2015-12-11 12:51:17 +00:00
|
|
|
core_info_list_t *core_info_list = NULL;
|
|
|
|
const core_info_t *core_info = NULL;
|
|
|
|
struct string_list *s = string_list_new();
|
2015-10-26 07:39:35 +00:00
|
|
|
|
2016-01-20 05:21:46 +00:00
|
|
|
if (!s || !len)
|
2016-05-23 19:28:43 +00:00
|
|
|
goto error;
|
2015-10-26 18:41:20 +00:00
|
|
|
|
2016-01-20 05:21:46 +00:00
|
|
|
attr.i = 0;
|
|
|
|
*len = 0;
|
2015-10-26 07:39:35 +00:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case STRING_LIST_MENU_DRIVERS:
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
for (i = 0; menu_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = menu_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 07:39:35 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 07:42:34 +00:00
|
|
|
#endif
|
|
|
|
case STRING_LIST_CAMERA_DRIVERS:
|
|
|
|
#ifdef HAVE_CAMERA
|
|
|
|
for (i = 0; camera_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = camera_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 07:42:34 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2016-09-21 14:06:14 +00:00
|
|
|
#endif
|
|
|
|
case STRING_LIST_WIFI_DRIVERS:
|
|
|
|
#ifdef HAVE_WIFI
|
|
|
|
for (i = 0; wifi_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = wifi_driver_find_ident(i);
|
|
|
|
*len += strlen(opt) + 1;
|
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 17:33:39 +00:00
|
|
|
#endif
|
|
|
|
case STRING_LIST_LOCATION_DRIVERS:
|
|
|
|
#ifdef HAVE_LOCATION
|
|
|
|
for (i = 0; location_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = location_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 17:33:39 +00:00
|
|
|
string_list_append(options_l, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 07:39:35 +00:00
|
|
|
#endif
|
2015-10-26 07:52:25 +00:00
|
|
|
case STRING_LIST_AUDIO_DRIVERS:
|
|
|
|
for (i = 0; audio_driver_find_handle(i); i++)
|
|
|
|
{
|
2015-10-26 07:55:59 +00:00
|
|
|
const char *opt = audio_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 07:55:59 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 17:41:13 +00:00
|
|
|
case STRING_LIST_AUDIO_RESAMPLER_DRIVERS:
|
|
|
|
for (i = 0; audio_resampler_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = audio_resampler_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 17:41:13 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 07:55:59 +00:00
|
|
|
case STRING_LIST_VIDEO_DRIVERS:
|
|
|
|
for (i = 0; video_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = video_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 07:52:25 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 07:59:23 +00:00
|
|
|
case STRING_LIST_INPUT_DRIVERS:
|
|
|
|
for (i = 0; input_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = input_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 07:59:23 +00:00
|
|
|
|
2015-10-26 08:06:11 +00:00
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 17:41:13 +00:00
|
|
|
case STRING_LIST_INPUT_HID_DRIVERS:
|
2016-06-07 01:01:33 +00:00
|
|
|
#ifdef HAVE_HID
|
2015-10-26 17:41:13 +00:00
|
|
|
for (i = 0; hid_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = hid_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 17:41:13 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
2016-06-07 01:01:33 +00:00
|
|
|
#endif
|
2015-10-26 17:41:13 +00:00
|
|
|
break;
|
2015-10-26 08:06:11 +00:00
|
|
|
case STRING_LIST_INPUT_JOYPAD_DRIVERS:
|
|
|
|
for (i = 0; joypad_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = joypad_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 08:06:11 +00:00
|
|
|
|
2015-10-26 07:59:23 +00:00
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 17:33:39 +00:00
|
|
|
case STRING_LIST_RECORD_DRIVERS:
|
|
|
|
for (i = 0; record_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = record_driver_find_ident(i);
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 17:33:39 +00:00
|
|
|
|
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 18:24:25 +00:00
|
|
|
case STRING_LIST_SUPPORTED_CORES_PATHS:
|
2016-05-09 16:11:17 +00:00
|
|
|
core_info_get_list(&core_info_list);
|
2015-12-11 12:51:17 +00:00
|
|
|
|
|
|
|
core_info_list_get_supported_cores(core_info_list,
|
2015-10-26 20:03:28 +00:00
|
|
|
(const char*)data, &core_info, list_size);
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2016-06-02 18:58:42 +00:00
|
|
|
if (!core_info)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-26 20:03:28 +00:00
|
|
|
if (*list_size == 0)
|
2015-10-26 18:41:20 +00:00
|
|
|
goto error;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2015-10-26 20:03:28 +00:00
|
|
|
for (i = 0; i < *list_size; i++)
|
2015-10-26 18:24:25 +00:00
|
|
|
{
|
|
|
|
const core_info_t *info = (const core_info_t*)&core_info[i];
|
2016-06-02 19:02:28 +00:00
|
|
|
const char *opt = info->path;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
|
|
|
if (!opt)
|
2015-10-26 18:41:20 +00:00
|
|
|
goto error;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2016-06-02 19:02:28 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 18:24:25 +00:00
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STRING_LIST_SUPPORTED_CORES_NAMES:
|
2016-05-09 16:11:17 +00:00
|
|
|
core_info_get_list(&core_info_list);
|
2015-12-11 12:51:17 +00:00
|
|
|
core_info_list_get_supported_cores(core_info_list,
|
2015-10-26 20:03:28 +00:00
|
|
|
(const char*)data, &core_info, list_size);
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2016-06-02 18:58:42 +00:00
|
|
|
if (!core_info)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-26 20:03:28 +00:00
|
|
|
if (*list_size == 0)
|
2015-10-26 18:41:20 +00:00
|
|
|
goto error;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2015-10-26 20:03:28 +00:00
|
|
|
for (i = 0; i < *list_size; i++)
|
2015-10-26 18:24:25 +00:00
|
|
|
{
|
2016-07-12 21:10:25 +00:00
|
|
|
core_info_t *info = (core_info_t*)&core_info[i];
|
|
|
|
const char *opt = info->display_name;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
|
|
|
if (!opt)
|
2015-10-26 18:41:20 +00:00
|
|
|
goto error;
|
2015-10-26 18:24:25 +00:00
|
|
|
|
2015-10-26 18:41:20 +00:00
|
|
|
*len += strlen(opt) + 1;
|
2015-10-26 18:24:25 +00:00
|
|
|
string_list_append(s, opt, attr);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-26 07:39:35 +00:00
|
|
|
case STRING_LIST_NONE:
|
|
|
|
default:
|
2015-10-26 18:41:20 +00:00
|
|
|
goto error;
|
2015-10-26 07:39:35 +00:00
|
|
|
}
|
|
|
|
|
2015-10-26 18:41:20 +00:00
|
|
|
return s;
|
|
|
|
|
|
|
|
error:
|
2015-10-26 18:42:27 +00:00
|
|
|
string_list_free(s);
|
2015-10-26 18:42:52 +00:00
|
|
|
s = NULL;
|
2015-10-26 18:41:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *char_list_new_special(enum string_list_type type, void *data)
|
|
|
|
{
|
2016-02-12 21:58:59 +00:00
|
|
|
unsigned len = 0;
|
2015-10-26 20:03:28 +00:00
|
|
|
size_t list_size;
|
|
|
|
struct string_list *s = string_list_new_special(type, data, &len, &list_size);
|
2015-10-26 18:41:20 +00:00
|
|
|
char *options = (len > 0) ? (char*)calloc(len, sizeof(char)): NULL;
|
2015-10-26 07:39:35 +00:00
|
|
|
|
2015-10-26 18:41:20 +00:00
|
|
|
if (options && s)
|
2015-10-26 07:39:35 +00:00
|
|
|
string_list_join_concat(options, len, s, "|");
|
|
|
|
|
|
|
|
string_list_free(s);
|
|
|
|
s = NULL;
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|