static void salamander_init(void) { CellPadData pad_data; cellPadInit(7); cellPadGetData(0, &pad_data); if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) { //override path, boot first executable in cores directory RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n"); find_and_set_first_file(); } else { //normal executable loading path char tmp_str[PATH_MAX]; bool config_file_exists = false; if (path_file_exists(config_path)) config_file_exists = true; //try to find CORE executable char core_executable[1024]; fill_pathname_join(core_executable, default_paths.core_dir, "CORE.SELF", sizeof(core_executable)); if(path_file_exists(core_executable)) { //Start CORE executable strlcpy(libretro_path, core_executable, sizeof(libretro_path)); RARCH_LOG("Start [%s].\n", libretro_path); } else { if (config_file_exists) { config_file_t * conf = config_file_new(config_path); config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); strlcpy(libretro_path, tmp_str, sizeof(libretro_path)); } if (!config_file_exists || !strcmp(libretro_path, "")) find_and_set_first_file(); else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); if (!config_file_exists) { config_file_t *new_conf = config_file_new(NULL); config_set_string(new_conf, "libretro_path", libretro_path); config_file_write(new_conf, config_path); config_file_free(new_conf); } } } cellPadEnd(); }
static void salamander_init_settings(void) { char tmp_str[512] = {0}; bool config_file_exists; if(!path_file_exists(default_paths.config_path)) { FILE * f; config_file_exists = false; RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", default_paths.config_path); MAKE_DIR(default_paths.port_dir); f = fopen(default_paths.config_path, "w"); fclose(f); } else config_file_exists = true; //try to find CORE executable char core_executable[1024]; snprintf(core_executable, sizeof(core_executable), "%s/CORE.dol", default_paths.core_dir); if(path_file_exists(core_executable)) { //Start CORE executable snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), core_executable); RARCH_LOG("Start [%s].\n", default_paths.libretro_path); } else { if(config_file_exists) { config_file_t * conf = config_file_new(default_paths.config_path); config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), tmp_str); } if(!config_file_exists || !strcmp(default_paths.libretro_path, "")) find_and_set_first_file(); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path); } if (!config_file_exists) { config_file_t *new_conf = config_file_new(NULL); config_set_string(new_conf, "libretro_path", default_paths.libretro_path); config_file_write(new_conf, default_paths.config_path); config_file_free(new_conf); } } }
static void salamander_init(void) { char tmp_str[512] = {0}; bool config_file_exists; if (path_file_exists(config_path)) config_file_exists = true; //try to find CORE executable char core_executable[1024]; fill_pathname_join(core_executable, default_paths.core_dir, "CORE.dol", sizeof(core_executable)); if(path_file_exists(core_executable)) { //Start CORE executable strlcpy(libretro_path, core_executable, sizeof(libretro_path)); RARCH_LOG("Start [%s].\n", libretro_path); } else { if(config_file_exists) { config_file_t * conf = config_file_new(config_path); if (!conf) // stupid libfat bug or something; somtimes it says the file is there when it doesn't config_file_exists = false; else { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); strlcpy(libretro_path, tmp_str, sizeof(libretro_path)); } } if(!config_file_exists || !strcmp(libretro_path, "")) find_and_set_first_file(); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); } if (!config_file_exists) { config_file_t *new_conf = config_file_new(NULL); config_set_string(new_conf, "libretro_path", libretro_path); config_file_write(new_conf, config_path); config_file_free(new_conf); } } }
// Rename core filename executable to a more sane name. static bool libretro_install_core(const char *path_prefix, const char *core_exe_path) { char old_path[PATH_MAX], new_path[PATH_MAX]; libretro_get_current_core_pathname(old_path, sizeof(old_path)); strlcat(old_path, DEFAULT_EXE_EXT, sizeof(old_path)); snprintf(new_path, sizeof(new_path), "%s%s", path_prefix, old_path); /* If core already exists, we are upgrading the core - * delete existing file first. */ if (path_file_exists(new_path)) { RARCH_LOG("Removing temporary ROM file: %s.\n", new_path); if (remove(new_path) < 0) RARCH_ERR("Failed to remove file: %s.\n", new_path); } /* Now attempt the renaming of the core. */ RARCH_LOG("Renaming core to: %s.\n", new_path); if (rename(core_exe_path, new_path) < 0) { RARCH_ERR("Failed to rename core.\n"); return false; } strlcpy(g_settings.libretro, new_path, sizeof(g_settings.libretro)); return true; }
static bool core_info_list_update_missing_firmware_internal( core_info_list_t *core_info_list, const char *core, const char *systemdir) { size_t i; char path[PATH_MAX_LENGTH] = {0}; core_info_t *info = NULL; if (!core_info_list || !core) return false; info = core_info_find_internal(core_info_list, core); if (!info) return false; for (i = 0; i < info->firmware_count; i++) { if (!info->firmware[i].path) continue; fill_pathname_join(path, systemdir, info->firmware[i].path, sizeof(path)); info->firmware[i].missing = !path_file_exists(path); } return true; }
static void glui_context_reset(void *data) { char bgpath[PATH_MAX]; glui_handle_t *glui = NULL; menu_handle_t *menu = (menu_handle_t*)data; gl_t *gl = (gl_t*)driver_video_resolve(NULL); (void)gl; driver.gfx_use_rgba = true; if (!menu) return; glui = (glui_handle_t*)menu->userdata; if (!glui) return; fill_pathname_join(bgpath, g_settings.assets_directory, "glui", sizeof(bgpath)); fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath)); if (path_file_exists(bgpath)) glui->bg = glui_png_texture_load(bgpath); printf("%d\n", glui->bg); }
HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { char path[PATH_MAX]; process_input_ret = 0; if(hObjPressed == m_menulist) { int index = XuiListGetCurSel(m_menulist, NULL); wcstombs(str_buffer, (const wchar_t *)XuiListGetText(m_menulist, index), sizeof(str_buffer)); if (path_file_exists(rgui->browser->list->elems[index].data)) { fill_pathname_join(g_extern.fullpath, rgui->browser->current_dir.directory_path, str_buffer, sizeof(g_extern.fullpath)); g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME); process_input_ret = -1; } else if(rgui->browser->list->elems[index].attr.b) { fill_pathname_join(path, rgui->browser->current_dir.directory_path, str_buffer, sizeof(path)); filebrowser_set_root_and_ext(rgui->browser, rgui->info.valid_extensions, path); filebrowser_fetch_directory_entries(RGUI_ACTION_OK); } } bHandled = TRUE; return 0; }
HRESULT CRetroArchCoreBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { char path[PATH_MAX]; process_input_ret = 0; if(hObjPressed == m_menulist) { int index = XuiListGetCurSel(m_menulist, NULL); wcstombs(str_buffer, (const wchar_t *)XuiListGetText(m_menulist, index), sizeof(str_buffer)); if(path_file_exists(rgui->browser->list->elems[index].data)) { fill_pathname_join(path, rgui->browser->current_dir.directory_path, str_buffer, sizeof(path)); rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)path); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); process_input_ret = -1; } else if (rgui->browser->list->elems[index].attr.b) { fill_pathname_join(path, rgui->browser->current_dir.directory_path, str_buffer, sizeof(path)); filebrowser_set_root_and_ext(rgui->browser, "xex|XEX", path); filebrowser_fetch_directory_entries(RGUI_ACTION_OK); } } bHandled = TRUE; return 0; }
static const char *font_renderer_stb_get_default_font(void) { static const char *paths[] = { #if defined(_WIN32) "C:\\Windows\\Fonts\\consola.ttf", "C:\\Windows\\Fonts\\verdana.ttf", #elif defined(__APPLE__) "/Library/Fonts/Microsoft/Candara.ttf", "/Library/Fonts/Verdana.ttf", "/Library/Fonts/Tahoma.ttf", #elif defined(__ANDROID_API__) "/system/fonts/DroidSansMono.ttf", "/system/fonts/CutiveMono.ttf", "/system/fonts/DroidSans.ttf", #else "/usr/share/fonts/TTF/DejaVuSansMono.ttf", "/usr/share/fonts/TTF/DejaVuSans.ttf", "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf", "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", #endif "osd-font.ttf", NULL }; const char **p; for (p = paths; *p; ++p) if (path_file_exists(*p)) return *p; return NULL; }
bool core_info_get_display_name(const char *path, char *s, size_t len) { char *core_name = NULL; config_file_t *conf = NULL; if (!path_file_exists(path)) return false; conf = config_file_new(path); if (!conf) goto error; config_get_string(conf, "corename", &core_name); config_file_free(conf); if (!core_name) goto error; if (!conf) return false; strlcpy(s, core_name, len); return true; error: return false; }
static void event_load_auto_state(void) { bool ret; char msg[PATH_MAX_LENGTH] = {0}; char savestate_name_auto[PATH_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); #ifdef HAVE_NETPLAY if (global->netplay_enable && !global->netplay_is_spectate) return; #endif if (!settings->savestate_auto_load) return; fill_pathname_noext(savestate_name_auto, global->savestate_name, ".auto", sizeof(savestate_name_auto)); if (!path_file_exists(savestate_name_auto)) return; ret = load_state(savestate_name_auto); RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); snprintf(msg, sizeof(msg), "Auto-loading savestate from \"%s\" %s.", savestate_name_auto, ret ? "succeeded" : "failed"); rarch_main_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); }
/** * menu_content_find_first_core: * @core_info : Core info list handle. * @dir : Directory. Gets joined with @path. * @path : Path. Gets joined with @dir. * @menu_label : Label identifier of menu setting. * @s : Deferred core path. Will be filled in * by function. * @len : Size of @s. * * Gets deferred core. * * Returns: false if there are multiple deferred cores and a * selection needs to be made from a list, otherwise * returns true and fills in @s with path to core. **/ static bool menu_content_find_first_core(void *data) { char new_core_path[PATH_MAX_LENGTH]; const core_info_t *info = NULL; size_t supported = 0; menu_content_ctx_defer_info_t *def_info = (menu_content_ctx_defer_info_t *)data; core_info_list_t *core_info = (core_info_list_t*)def_info->data; uint32_t menu_label_hash = menu_hash_calculate(def_info->menu_label); if ( !string_is_empty(def_info->dir) && !string_is_empty(def_info->path)) fill_pathname_join(def_info->s, def_info->dir, def_info->path, def_info->len); #ifdef HAVE_COMPRESSION if (path_is_compressed_file(def_info->dir)) { /* In case of a compressed archive, we have to join with a hash */ /* We are going to write at the position of dir: */ retro_assert(strlen(def_info->dir) < strlen(def_info->s)); def_info->s[strlen(def_info->dir)] = '#'; } #endif if (core_info) core_info_list_get_supported_cores(core_info, def_info->s, &info, &supported); /* We started the menu with 'Load Content', we are * going to use the current core to load this. */ if (menu_label_hash == MENU_LABEL_LOAD_CONTENT) { core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, (void*)&info); if (info) { RARCH_LOG("Use the current core (%s) to load this content...\n", info->path); supported = 1; } } /* There are multiple deferred cores and a * selection needs to be made from a list, return 0. */ if (supported != 1) return false; if (info) strlcpy(new_core_path, info->path, sizeof(new_core_path)); runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, def_info->s); if (path_file_exists(new_core_path)) runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, new_core_path); return true; }
HRESULT CRetroArchCoreBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { char path[PATH_MAX]; if(hObjPressed == m_romlist) { int index = m_romlist.GetCurSel(); convert_wchar_to_char(str_buffer, (const wchar_t *)m_romlist.GetText(index), sizeof(str_buffer)); if(path_file_exists(tmp_browser.current_dir.list->elems[index].data)) { snprintf(g_extern.console.external_launch.launch_app, sizeof(g_extern.console.external_launch.launch_app), "%s\\%s", filebrowser_get_current_dir(&tmp_browser), str_buffer); rarch_settings_change(S_RETURN_TO_LAUNCHER); } else if(tmp_browser.current_dir.list->elems[index].attr.b) { snprintf(path, sizeof(path), "%s\\%s", filebrowser_get_current_dir(&tmp_browser), str_buffer); filebrowser_set_root_and_ext(&tmp_browser, "xex|XEX", path); uint64_t action = (1ULL << RMENU_DEVICE_NAV_B); filebrowser_fetch_directory_entries(&tmp_browser, action, &m_romlist, &m_rompathtitle); } } bHandled = TRUE; return 0; }
void core_info_list_get_missing_firmware(core_info_list_t *core_info_list, const char *core, const char *systemdir, const core_info_firmware_t **firmware, size_t *num_firmware) { size_t i; char path[PATH_MAX]; core_info_t *info = NULL; if (!core_info_list || !core) return; *firmware = NULL; *num_firmware = 0; if (!(info = find_core_info(core_info_list, core))) return; *firmware = info->firmware; for (i = 1; i < info->firmware_count; i++) { fill_pathname_join(path, systemdir, info->firmware[i].path, sizeof(path)); info->firmware[i].missing = !path_file_exists(path); *num_firmware += info->firmware[i].missing; } qsort(info->firmware, info->firmware_count, sizeof(*info->firmware), core_info_firmware_cmp); }
static int action_ok_remap_file_save_game(const char *path, const char *label, unsigned type, size_t idx) { global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); const char *core_name; core_name = global->system.info.library_name; const char *game_name; game_name = path_basename(global->basename); char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH); fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH); if(!path_file_exists(directory)) path_mkdir(directory); if(input_remapping_save_file(file)) rarch_main_msg_queue_push("Remap file saved successfully", 1, 100, true); else rarch_main_msg_queue_push("Error saving remap file", 1, 100, true); return 0; }
static void nk_menu_context_reset_textures(nk_menu_handle_t *nk, const char *iconpath) { unsigned i; for (i = 0; i < NK_TEXTURE_LAST; i++) { struct texture_image ti = {0}; char path[PATH_MAX_LENGTH] = {0}; switch(i) { case NK_TEXTURE_POINTER: fill_pathname_join(path, iconpath, "pointer.png", sizeof(path)); break; } if (string_is_empty(path) || !path_file_exists(path)) continue; image_texture_load(&ti, path); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &nk->textures.list[i]); image_texture_load(&ti, path); } }
static int action_ok_menu_wallpaper_load(const char *path, const char *label, unsigned type, size_t idx) { char wallpaper_path[PATH_MAX_LENGTH]; const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) return -1; menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); setting = menu_setting_find(menu_label); if (!setting) return -1; fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path)); if (path_file_exists(wallpaper_path)) { strlcpy(settings->menu.wallpaper, wallpaper_path, sizeof(settings->menu.wallpaper)); rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, wallpaper_path, "cb_menu_wallpaper", 0, 1, true); } menu_list_pop_stack_by_needle(menu->menu_list, setting->name); return 0; }
bool rarch_configure_libretro_core(const char *full_path, const char *tmp_path, const char *libretro_path, const char *config_path, const char *extension) { bool libretro_core_was_installed = false; bool find_libretro_file = false; char libretro_core_installed[1024]; g_extern.verbose = true; //install and rename libretro core first if 'CORE' executable exists if (path_file_exists(full_path)) libretro_core_was_installed = rarch_manage_libretro_install( libretro_core_installed, sizeof(libretro_core_installed), full_path, tmp_path, extension); g_extern.verbose = false; //if we have just installed a libretro core, set libretro path in settings to newly installed libretro core if(libretro_core_was_installed) strlcpy(g_settings.libretro, libretro_core_installed, sizeof(g_settings.libretro)); else find_libretro_file = true; return find_libretro_file; }
/* When selection is presented back, returns 0. * If it can make a decision right now, returns -1. */ int menu_defer_core(core_info_list_t *core_info, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path) { const core_info_t *info = NULL; size_t supported = 0; fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path); if (core_info) core_info_list_get_supported_cores(core_info, deferred_path, &info, &supported); /* Can make a decision right now. */ if (supported == 1) { strlcpy(g_extern.fullpath, deferred_path, sizeof(g_extern.fullpath)); if (path_file_exists(info->path)) strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro)); #ifdef HAVE_DYNAMIC g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); #else rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath); #endif return -1; } return 0; }
static void init_settings(void) { char tmp_str[PATH_MAX]; bool config_file_exists; if(!path_file_exists(SYS_CONFIG_FILE)) { FILE * f; config_file_exists = false; RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", SYS_CONFIG_FILE); f = fopen(SYS_CONFIG_FILE, "w"); fclose(f); } else config_file_exists = true; //try to find CORE executable char core_executable[1024]; #if defined(_XBOX) snprintf(core_executable, sizeof(core_executable), "game:\\CORE.xex"); #elif defined(__CELLOS_LV2__) snprintf(core_executable, sizeof(core_executable), "%s/CORE.SELF", LIBRETRO_DIR_PATH); #endif if(path_file_exists(core_executable)) { //Start CORE executable snprintf(libretro_path, sizeof(libretro_path), core_executable); RARCH_LOG("Start [%s].\n", libretro_path); } else { if(config_file_exists) { config_file_t * conf = config_file_new(SYS_CONFIG_FILE); config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); snprintf(libretro_path, sizeof(libretro_path), tmp_str); } if(!config_file_exists || !strcmp(libretro_path, "")) find_and_set_first_file(); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); } } }
int main(int argc, char *argv[]) { get_environment_settings(); rarch_main_clear_state(); config_set_defaults(); char full_path[1024]; snprintf(full_path, sizeof(full_path), "game:\\CORE.xex"); bool find_libretro_file = rarch_configure_libretro_core(full_path, "game:\\", "game:\\", SYS_CONFIG_FILE, ".xex"); set_default_settings(); rarch_config_load(SYS_CONFIG_FILE, "game:\\", ".xex", find_libretro_file); init_libretro_sym(); video_xdk360.start(); input_xdk360.init(); rarch_input_set_default_keybind_names_for_emulator(); menu_init(); begin_loop: if(g_console.mode_switch == MODE_EMULATION) { bool repeat = false; input_xdk360.poll(NULL); rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); do{ repeat = rarch_main_iterate(); }while(repeat && !g_console.frame_advance_enable); } else if(g_console.mode_switch == MODE_MENU) { menu_loop(); rarch_startup(SYS_CONFIG_FILE); } else goto begin_shutdown; goto begin_loop; begin_shutdown: if(path_file_exists(SYS_CONFIG_FILE)) rarch_config_save(SYS_CONFIG_FILE); menu_free(); video_xdk360.stop(); input_xdk360.free(NULL); rarch_exec(); return 0; }
static void check_default_dirs(void) { /* early return for people with a custom folder setup so it doesn't create unnecessary directories */ if (path_file_exists("custom.ini")) return; if (*g_defaults.dir.core_assets) check_defaults_dir_create_dir(g_defaults.dir.core_assets); if (*g_defaults.dir.remap) check_defaults_dir_create_dir(g_defaults.dir.remap); if (*g_defaults.dir.screenshot) check_defaults_dir_create_dir(g_defaults.dir.screenshot); if (*g_defaults.dir.core) check_defaults_dir_create_dir(g_defaults.dir.core); if (*g_defaults.dir.autoconfig) check_defaults_dir_create_dir(g_defaults.dir.autoconfig); if (*g_defaults.dir.audio_filter) check_defaults_dir_create_dir(g_defaults.dir.audio_filter); if (*g_defaults.dir.video_filter) check_defaults_dir_create_dir(g_defaults.dir.video_filter); if (*g_defaults.dir.assets) check_defaults_dir_create_dir(g_defaults.dir.assets); if (*g_defaults.dir.playlist) check_defaults_dir_create_dir(g_defaults.dir.playlist); if (*g_defaults.dir.core) check_defaults_dir_create_dir(g_defaults.dir.core); if (*g_defaults.dir.core_info) check_defaults_dir_create_dir(g_defaults.dir.core_info); if (*g_defaults.dir.overlay) check_defaults_dir_create_dir(g_defaults.dir.overlay); if (*g_defaults.dir.port) check_defaults_dir_create_dir(g_defaults.dir.port); if (*g_defaults.dir.shader) check_defaults_dir_create_dir(g_defaults.dir.shader); if (*g_defaults.dir.savestate) check_defaults_dir_create_dir(g_defaults.dir.savestate); if (*g_defaults.dir.sram) check_defaults_dir_create_dir(g_defaults.dir.sram); if (*g_defaults.dir.system) check_defaults_dir_create_dir(g_defaults.dir.system); if (*g_defaults.dir.resampler) check_defaults_dir_create_dir(g_defaults.dir.resampler); if (*g_defaults.dir.menu_config) check_defaults_dir_create_dir(g_defaults.dir.menu_config); if (*g_defaults.dir.content_history) check_defaults_dir_create_dir(g_defaults.dir.content_history); if (*g_defaults.dir.cache) check_defaults_dir_create_dir(g_defaults.dir.cache); if (*g_defaults.dir.database) check_defaults_dir_create_dir(g_defaults.dir.database); if (*g_defaults.dir.cursor) check_defaults_dir_create_dir(g_defaults.dir.cursor); if (*g_defaults.dir.cheats) check_defaults_dir_create_dir(g_defaults.dir.cheats); if (*g_defaults.dir.thumbnails) check_defaults_dir_create_dir(g_defaults.dir.thumbnails); }
bool core_info_has_custom_config(const char *core_id) { char path[PATH_MAX]; if (!core_id) return false; core_info_get_custom_config(core_id, path, sizeof(path)); return path_file_exists(path); }
// Highly OS/platform dependent. static const char *ft_renderer_get_default_font(void) { for (size_t i = 0; i < sizeof(font_paths) / sizeof(font_paths[0]); i++) { if (path_file_exists(font_paths[i])) return font_paths[i]; } return NULL; }
static void salamander_init(char *s, size_t len) { /* normal executable loading path */ bool config_file_exists = false; if (path_file_exists(g_defaults.path.config)) config_file_exists = true; if (config_file_exists) { char tmp_str[PATH_MAX_LENGTH]; config_file_t * conf = (config_file_t*)config_file_new(g_defaults.path.config); if (conf) { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); if (strcmp(tmp_str, "builtin") != 0) strlcpy(s, tmp_str, len); } #ifdef GEKKO /* stupid libfat bug or something; sometimes it says * the file is there when it doesn't. */ else { config_file_exists = false; } #endif } if (!config_file_exists || !strcmp(s, "")) { char executable_name[PATH_MAX_LENGTH]; frontend_driver_get_core_extension( executable_name, sizeof(executable_name)); find_and_set_first_file(s, len, executable_name); } else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", s); if (!config_file_exists) { config_file_t *conf = (config_file_t*)config_file_new(NULL); if (conf) { config_set_string(conf, "libretro_path", s); config_file_write(conf, g_defaults.path.config); config_file_free(conf); } } }
static void rarch_get_environment(int argc, char *argv[]) { g_extern.verbose = true; #if defined(HAVE_LOGGER) logger_init(); #elif defined(HAVE_FILE_LOGGER) g_extern.log_file = fopen("/retroarch-log.txt", "w"); #endif if (frontend_ctx && frontend_ctx->environment_get) frontend_ctx->environment_get(argc, argv); config_load(); #if defined(RARCH_CONSOLE) init_libretro_sym(false); rarch_init_system_info(); global_init_drivers(); #ifdef HAVE_LIBRETRO_MANAGEMENT char path_prefix[PATH_MAX]; #if defined(_WIN32) char slash = '\\'; #else char slash = '/'; #endif snprintf(path_prefix, sizeof(path_prefix), "%s%c", default_paths.core_dir, slash); char core_exe_path[256]; snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, DEFAULT_EXE_EXT); // Save new libretro core path to config file and exit if (path_file_exists(core_exe_path)) if (libretro_install_core(path_prefix, core_exe_path)) #ifdef _XBOX g_extern.system.shutdown = g_extern.system.shutdown; #else g_extern.system.shutdown = true; #endif #endif #ifdef GEKKO /* Per-core input config loading */ char core_name[64]; libretro_get_current_core_pathname(core_name, sizeof(core_name)); snprintf(g_extern.input_config_path, sizeof(g_extern.input_config_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name); config_read_keybinds(g_extern.input_config_path); #endif #endif }
static void mui_context_reset_textures(mui_handle_t *mui, const char *iconpath) { unsigned i; for (i = 0; i < MUI_TEXTURE_LAST; i++) { struct texture_image ti = {0}; char path[PATH_MAX_LENGTH] = {0}; switch(i) { case MUI_TEXTURE_POINTER: fill_pathname_join(path, iconpath, "pointer.png", sizeof(path)); break; case MUI_TEXTURE_BACK: fill_pathname_join(path, iconpath, "back.png", sizeof(path)); break; case MUI_TEXTURE_SWITCH_ON: fill_pathname_join(path, iconpath, "on.png", sizeof(path)); break; case MUI_TEXTURE_SWITCH_OFF: fill_pathname_join(path, iconpath, "off.png", sizeof(path)); break; case MUI_TEXTURE_TAB_MAIN_ACTIVE: fill_pathname_join(path, iconpath, "main_tab_active.png", sizeof(path)); break; case MUI_TEXTURE_TAB_PLAYLISTS_ACTIVE: fill_pathname_join(path, iconpath, "playlists_tab_active.png", sizeof(path)); break; case MUI_TEXTURE_TAB_SETTINGS_ACTIVE: fill_pathname_join(path, iconpath, "settings_tab_active.png", sizeof(path)); break; case MUI_TEXTURE_TAB_MAIN_PASSIVE: fill_pathname_join(path, iconpath, "main_tab_passive.png", sizeof(path)); break; case MUI_TEXTURE_TAB_PLAYLISTS_PASSIVE: fill_pathname_join(path, iconpath, "playlists_tab_passive.png", sizeof(path)); break; case MUI_TEXTURE_TAB_SETTINGS_PASSIVE: fill_pathname_join(path, iconpath, "settings_tab_passive.png", sizeof(path)); break; } if (string_is_empty(path) || !path_file_exists(path)) continue; video_texture_image_load(&ti, path); mui->textures.list[i].id = menu_display_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR); video_texture_image_free(&ti); } }
static int cb_update_shaders_glsl(void *data, size_t len) { char shaderdir[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); fill_pathname_join(shaderdir, settings->video.shader_dir, "shaders_glsl", sizeof(shaderdir)); if (!path_file_exists(shaderdir)) if (!path_mkdir(shaderdir)) return -1; return cb_generic_download(data, len, shaderdir); }
/* Highly OS/platform dependent. */ static const char *font_renderer_ft_get_default_font(void) { size_t i; for (i = 0; i < ARRAY_SIZE(font_paths); i++) { if (path_file_exists(font_paths[i])) return font_paths[i]; } return NULL; }
/** * rarch_defer_core: * @core_info : Core info list handle. * @dir : Directory. Gets joined with @path. * @path : Path. Gets joined with @dir. * @menu_label : Label identifier of menu setting. * @s : Deferred core path. Will be filled in * by function. * @len : Size of @s. * * Gets deferred core. * * Returns: 0 if there are multiple deferred cores and a * selection needs to be made from a list, otherwise * returns -1 and fills in @s with path to core. **/ int rarch_defer_core(core_info_list_t *core_info, const char *dir, const char *path, const char *menu_label, char *s, size_t len) { char new_core_path[PATH_MAX_LENGTH] = {0}; const core_info_t *info = NULL; size_t supported = 0; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); uint32_t menu_label_hash = msg_hash_calculate(menu_label); fill_pathname_join(s, dir, path, len); #ifdef HAVE_COMPRESSION if (path_is_compressed_file(dir)) { /* In case of a compressed archive, we have to join with a hash */ /* We are going to write at the position of dir: */ rarch_assert(strlen(dir) < strlen(s)); s[strlen(dir)] = '#'; } #endif if (core_info) core_info_list_get_supported_cores(core_info, s, &info, &supported); if (menu_label_hash == MENU_LABEL_LOAD_CONTENT) { info = (const core_info_t*)&global->core_info.current; if (info) { strlcpy(new_core_path, info->path, sizeof(new_core_path)); supported = 1; } } else strlcpy(new_core_path, info->path, sizeof(new_core_path)); /* There are multiple deferred cores and a * selection needs to be made from a list, return 0. */ if (supported != 1) return 0; strlcpy(global->path.fullpath, s, sizeof(global->path.fullpath)); if (path_file_exists(new_core_path)) strlcpy(settings->libretro, new_core_path, sizeof(settings->libretro)); return -1; }