static 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_LENGTH]; core_info_t *info = NULL; if (!core_info_list || !core) return; path[0] = '\0'; *firmware = NULL; *num_firmware = 0; info = core_info_find_internal(core_info_list, core); if (!info) 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 = !filestream_exists(path); *num_firmware += info->firmware[i].missing; } qsort(info->firmware, info->firmware_count, sizeof(*info->firmware), core_info_firmware_cmp); }
static void frontend_ps3_process_args(int *argc, char *argv[]) { #ifndef IS_SALAMANDER /* A big hack: sometimes Salamander doesn't save the new core * it loads on first boot, so we make sure * active core path is set here. */ if (*argc >= 1) { char path[PATH_MAX_LENGTH] = {0}; strlcpy(path, argv[0], sizeof(path)); if (filestream_exists(path)) rarch_ctl(RARCH_CTL_SET_LIBRETRO_PATH, path); } #endif }
static bool core_info_list_update_missing_firmware_internal( core_info_list_t *core_info_list, const char *core, const char *systemdir, bool *set_missing_bios) { size_t i; core_info_t *info = NULL; char *path = NULL; size_t path_size = PATH_MAX_LENGTH * sizeof(char); if (!core_info_list || !core) return false; info = core_info_find_internal(core_info_list, core); if (!info) return false; path = (char*)malloc(path_size); if (!path) return false; path[0] = '\0'; for (i = 0; i < info->firmware_count; i++) { if (string_is_empty(info->firmware[i].path)) continue; fill_pathname_join(path, systemdir, info->firmware[i].path, path_size); info->firmware[i].missing = !filestream_exists(path); if (info->firmware[i].missing && !info->firmware[i].optional) { *set_missing_bios = true; RARCH_WARN("Firmware missing: %s\n", info->firmware[i].path); } } free(path); return true; }
static void extractCB(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; MainWindow *mainwindow = (MainWindow*)user_data; if (err) RARCH_ERR("%s", err); if (dec) { if (filestream_exists(dec->source_file)) filestream_delete(dec->source_file); free(dec->source_file); free(dec); } mainwindow->onUpdateRetroArchFinished(string_is_empty(err)); }
void print_buf_lines(file_list_t *list, char *buf, const char *label, int buf_size, enum msg_file_type type, bool append, bool extended) { char c; int i, j = 0; char *line_start = buf; if (!buf || !buf_size) { menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY), msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY), MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY, FILE_TYPE_NONE, 0, 0); return; } for (i = 0; i < buf_size; i++) { size_t ln; const char *core_date = NULL; const char *core_crc = NULL; const char *core_pathname = NULL; struct string_list *str_list = NULL; /* The end of the buffer, print the last bit */ if (*(buf + i) == '\0') break; if (*(buf + i) != '\n') continue; /* Found a line ending, print the line and compute new line_start */ /* Save the next char */ c = *(buf + i + 1); /* replace with \0 */ *(buf + i + 1) = '\0'; /* We need to strip the newline. */ ln = strlen(line_start) - 1; if (line_start[ln] == '\n') line_start[ln] = '\0'; str_list = string_split(line_start, " "); if (str_list->elems[0].data) core_date = str_list->elems[0].data; if (str_list->elems[1].data) core_crc = str_list->elems[1].data; if (str_list->elems[2].data) core_pathname = str_list->elems[2].data; (void)core_date; (void)core_crc; if (extended) { if (append) menu_entries_append_enum(list, core_pathname, "", MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); else menu_entries_prepend(list, core_pathname, "", MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); } else { if (append) menu_entries_append_enum(list, line_start, label, MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); else menu_entries_prepend(list, line_start, label, MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); } switch (type) { case FILE_TYPE_DOWNLOAD_CORE: { settings_t *settings = config_get_ptr(); if (settings) { char display_name[255]; char core_path[PATH_MAX_LENGTH]; char *last = NULL; display_name[0] = core_path[0] = '\0'; fill_pathname_join_noext( core_path, settings->paths.path_libretro_info, (extended && !string_is_empty(core_pathname)) ? core_pathname : line_start, sizeof(core_path)); path_remove_extension(core_path); last = (char*)strrchr(core_path, '_'); if (!string_is_empty(last)) { if (string_is_not_equal_fast(last, "_libretro", 9)) *last = '\0'; } strlcat(core_path, file_path_str(FILE_PATH_CORE_INFO_EXTENSION), sizeof(core_path)); if ( filestream_exists(core_path) && core_info_get_display_name( core_path, display_name, sizeof(display_name))) file_list_set_alt_at_offset(list, j, display_name); } } break; default: case FILE_TYPE_NONE: break; } j++; string_list_free(str_list); /* Restore the saved char */ *(buf + i + 1) = c; line_start = buf + i + 1; } if (append) file_list_sort_on_alt(list); /* If the buffer was completely full, and didn't end * with a newline, just ignore the partial last line. */ }
/* Parses log file referenced by runtime_log->path. * Does nothing if log file does not exist. */ static void runtime_log_read_file(runtime_log_t *runtime_log) { unsigned runtime_hours = 0; unsigned runtime_minutes = 0; unsigned runtime_seconds = 0; unsigned last_played_year = 0; unsigned last_played_month = 0; unsigned last_played_day = 0; unsigned last_played_hour = 0; unsigned last_played_minute = 0; unsigned last_played_second = 0; RtlJSONContext context = {0}; RFILE *file = NULL; int ret = 0; /* Check if log file exists */ if (!filestream_exists(runtime_log->path)) return; /* Attempt to open log file */ file = filestream_open(runtime_log->path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { RARCH_ERR("Failed to open runtime log file: %s\n", runtime_log->path); return; } /* Initialise JSON parser */ context.runtime_string = NULL; context.last_played_string = NULL; context.parser = JSON_Parser_Create(NULL); context.file = file; if (!context.parser) { RARCH_ERR("Failed to create JSON parser.\n"); goto end; } /* Configure parser */ JSON_Parser_SetAllowBOM(context.parser, JSON_True); JSON_Parser_SetStringHandler(context.parser, &RtlJSONStringHandler); JSON_Parser_SetObjectMemberHandler(context.parser, &RtlJSONObjectMemberHandler); JSON_Parser_SetUserData(context.parser, &context); /* Read file */ while (!filestream_eof(file)) { /* Runtime log files are tiny - use small chunk size */ char chunk[128] = {0}; int64_t length = filestream_read(file, chunk, sizeof(chunk)); /* Error checking... */ if (!length && !filestream_eof(file)) { RARCH_ERR("Failed to read runtime log file: %s\n", runtime_log->path); JSON_Parser_Free(context.parser); goto end; } /* Parse chunk */ if (!JSON_Parser_Parse(context.parser, chunk, length, JSON_False)) { RARCH_ERR("Error parsing chunk of runtime log file: %s\n---snip---\n%s\n---snip---\n", runtime_log->path, chunk); RtlJSONLogError(&context); JSON_Parser_Free(context.parser); goto end; } } /* Finalise parsing */ if (!JSON_Parser_Parse(context.parser, NULL, 0, JSON_True)) { RARCH_WARN("Error parsing runtime log file: %s\n", runtime_log->path); RtlJSONLogError(&context); JSON_Parser_Free(context.parser); goto end; } /* Free parser */ JSON_Parser_Free(context.parser); /* Process string values read from JSON file */ /* Runtime */ ret = 0; if (!string_is_empty(context.runtime_string)) ret = sscanf(context.runtime_string, LOG_FILE_RUNTIME_FORMAT_STR, &runtime_hours, &runtime_minutes, &runtime_seconds); if (ret != 3) { RARCH_ERR("Runtime log file - invalid 'runtime' entry detected: %s\n", runtime_log->path); goto end; } /* Last played */ ret = 0; if (!string_is_empty(context.last_played_string)) ret = sscanf(context.last_played_string, LOG_FILE_LAST_PLAYED_FORMAT_STR, &last_played_year, &last_played_month, &last_played_day, &last_played_hour, &last_played_minute, &last_played_second); if (ret != 6) { RARCH_ERR("Runtime log file - invalid 'last played' entry detected: %s\n", runtime_log->path); goto end; } /* If we reach this point then all is well * > Assign values to runtime_log object */ runtime_log->runtime.hours = runtime_hours; runtime_log->runtime.minutes = runtime_minutes; runtime_log->runtime.seconds = runtime_seconds; runtime_log->last_played.year = last_played_year; runtime_log->last_played.month = last_played_month; runtime_log->last_played.day = last_played_day; runtime_log->last_played.hour = last_played_hour; runtime_log->last_played.minute = last_played_minute; runtime_log->last_played.second = last_played_second; end: /* Clean up leftover strings */ if (context.runtime_string) free(context.runtime_string); if (context.last_played_string) free(context.last_played_string); /* Close log file */ filestream_close(file); }
static void frontend_ps3_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); verbosity_enable(); #endif (void)args; #ifndef IS_SALAMANDER #if defined(HAVE_LOGGER) logger_init(); #elif defined(HAVE_FILE_LOGGER) retro_main_log_file_init("/retroarch-log.txt"); #endif #endif int ret; unsigned int get_type; unsigned int get_attributes; CellGameContentSize size; char dirName[CELL_GAME_DIRNAME_SIZE] = {0}; #ifdef HAVE_MULTIMAN /* not launched from external launcher, set default path */ // second param is multiMAN SELF file if ( filestream_exists(argv[2]) && *argc > 1 && (string_is_equal(argv[2], EMULATOR_CONTENT_DIR))) { multiman_detected = true; RARCH_LOG("Started from multiMAN, auto-game start enabled.\n"); } else #endif #ifndef IS_SALAMANDER if (*argc > 1 && !string_is_empty(argv[1])) { static char path[PATH_MAX_LENGTH] = {0}; struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; if (args) { strlcpy(path, argv[1], sizeof(path)); args->touched = true; args->no_content = false; args->verbose = false; args->config_path = NULL; args->sram_path = NULL; args->state_path = NULL; args->content_path = path; args->libretro_path = NULL; RARCH_LOG("argv[0]: %s\n", argv[0]); RARCH_LOG("argv[1]: %s\n", argv[1]); RARCH_LOG("argv[2]: %s\n", argv[2]); RARCH_LOG("Auto-start game %s.\n", argv[1]); } } else RARCH_WARN("Started from Salamander, auto-game start disabled.\n"); #endif memset(&size, 0x00, sizeof(CellGameContentSize)); ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName); if(ret < 0) { RARCH_ERR("cellGameBootCheck() Error: 0x%x.\n", ret); } else { char content_info_path[PATH_MAX_LENGTH] = {0}; RARCH_LOG("cellGameBootCheck() OK.\n"); RARCH_LOG("Directory name: [%s].\n", dirName); RARCH_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB); switch(get_type) { case CELL_GAME_GAMETYPE_DISC: RARCH_LOG("RetroArch was launched on Optical Disc Drive.\n"); break; case CELL_GAME_GAMETYPE_HDD: RARCH_LOG("RetroArch was launched on HDD.\n"); break; } if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); ret = cellGameContentPermit(content_info_path, g_defaults.dirs[DEFAULT_DIR_PORT]); #ifdef HAVE_MULTIMAN if (multiman_detected) { fill_pathname_join(content_info_path, "/dev_hdd0/game/", EMULATOR_CONTENT_DIR, sizeof(content_info_path)); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PORT], content_info_path, "USRDIR", sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); } #endif if(ret < 0) RARCH_ERR("cellGameContentPermit() Error: 0x%x\n", ret); else { RARCH_LOG("cellGameContentPermit() OK.\n"); RARCH_LOG("content_info_path : [%s].\n", content_info_path); RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dirs[DEFAULT_DIR_PORT]); } strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], g_defaults.dirs[DEFAULT_DIR_PORT], sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT], "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], g_defaults.dirs[DEFAULT_DIR_CORE], "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], g_defaults.dirs[DEFAULT_DIR_CORE], "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], g_defaults.dirs[DEFAULT_DIR_CORE], "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], g_defaults.dirs[DEFAULT_DIR_CORE], "shaders_cg", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_PORT], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], g_defaults.dirs[DEFAULT_DIR_CORE], "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], g_defaults.dirs[DEFAULT_DIR_CORE], "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], g_defaults.dirs[DEFAULT_DIR_CORE], "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], g_defaults.dirs[DEFAULT_DIR_CORE], "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], g_defaults.dirs[DEFAULT_DIR_CORE], "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], g_defaults.dirs[DEFAULT_DIR_CORE], "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], g_defaults.dirs[DEFAULT_DIR_CORE], "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], g_defaults.dirs[DEFAULT_DIR_CORE], "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); } #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) { unsigned i; const char *title; char title_noext[255]; char *chr; bool hyphen_found; size_t list_size = ozone_list_get_size(ozone, MENU_LIST_HORIZONTAL); for (i = 0; i < list_size; i++) { const char *path = NULL; ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i); if (!node) { node = ozone_alloc_node(); if (!node) continue; } file_list_get_at_offset(ozone->horizontal_list, i, &path, NULL, NULL, NULL); if (!path) continue; if (!strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION))) continue; { struct texture_image ti; char *sysname = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); char *texturepath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); char *content_texturepath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); char *icons_path = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); strlcpy(icons_path, ozone->icons_path, PATH_MAX_LENGTH * sizeof(char)); sysname[0] = texturepath[0] = content_texturepath[0] = '\0'; fill_pathname_base_noext(sysname, path, PATH_MAX_LENGTH * sizeof(char)); fill_pathname_join_concat(texturepath, icons_path, sysname, file_path_str(FILE_PATH_PNG_EXTENSION), PATH_MAX_LENGTH * sizeof(char)); /* If the playlist icon doesn't exist return default */ if (!filestream_exists(texturepath)) fill_pathname_join_concat(texturepath, icons_path, "default", file_path_str(FILE_PATH_PNG_EXTENSION), PATH_MAX_LENGTH * sizeof(char)); ti.width = 0; ti.height = 0; ti.pixels = NULL; ti.supports_rgba = video_driver_supports_rgba(); if (image_texture_load(&ti, texturepath)) { if(ti.pixels) { video_driver_texture_unload(&node->icon); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &node->icon); } image_texture_free(&ti); } fill_pathname_join_delim(sysname, sysname, file_path_str(FILE_PATH_CONTENT_BASENAME), '-', PATH_MAX_LENGTH * sizeof(char)); strlcat(content_texturepath, icons_path, PATH_MAX_LENGTH * sizeof(char)); strlcat(content_texturepath, path_default_slash(), PATH_MAX_LENGTH * sizeof(char)); strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char)); /* If the content icon doesn't exist return default-content */ if (!filestream_exists(content_texturepath)) { strlcat(icons_path, path_default_slash(), PATH_MAX_LENGTH * sizeof(char)); strlcat(icons_path, "default", PATH_MAX_LENGTH * sizeof(char)); fill_pathname_join_delim(content_texturepath, icons_path, file_path_str(FILE_PATH_CONTENT_BASENAME), '-', PATH_MAX_LENGTH * sizeof(char)); } if (image_texture_load(&ti, content_texturepath)) { if(ti.pixels) { video_driver_texture_unload(&node->content_icon); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &node->content_icon); } image_texture_free(&ti); } /* Console name */ menu_entries_get_at_offset( ozone->horizontal_list, i, &title, NULL, NULL, NULL, NULL); fill_pathname_base_noext(title_noext, title, sizeof(title_noext)); /* Format : "Vendor - Console" Remove everything before the hyphen and the subsequent space */ chr = title_noext; hyphen_found = false; while (true) { if (*chr == '-') { hyphen_found = true; break; } else if (*chr == '\0') break; chr++; } if (hyphen_found) chr += 2; else chr = title_noext; if (node->console_name) free(node->console_name); node->console_name = strdup(chr); free(sysname); free(texturepath); free(content_texturepath); free(icons_path); } } }
void ShaderParamsDialog::saveShaderPreset(const char *path, unsigned action_type) { char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; char tmp[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); struct retro_system_info *system = runloop_get_libretro_system_info(); const char *core_name = system ? system->library_name : NULL; directory[0] = file[0] = tmp[0] = '\0'; if (!string_is_empty(core_name)) { fill_pathname_join( tmp, settings->paths.directory_video_shader, "presets", sizeof(tmp)); fill_pathname_join( directory, tmp, core_name, sizeof(directory)); } if (!filestream_exists(directory)) path_mkdir(directory); switch (action_type) { case SHADER_PRESET_SAVE_CORE: if (!string_is_empty(core_name)) fill_pathname_join(file, directory, core_name, sizeof(file)); break; case SHADER_PRESET_SAVE_GAME: { const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); fill_pathname_join(file, directory, game_name, sizeof(file)); break; } case SHADER_PRESET_SAVE_PARENT: fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp)); fill_pathname_join(file, directory, tmp, sizeof(file)); break; case SHADER_PRESET_SAVE_NORMAL: default: if (!string_is_empty(path)) strlcpy(file, path, sizeof(file)); break; } if (menu_shader_manager_save_preset(file, false, true)) runloop_msg_queue_push( msg_hash_to_str(MSG_SHADER_PRESET_SAVED_SUCCESSFULLY), 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO ); else runloop_msg_queue_push( msg_hash_to_str(MSG_ERROR_SAVING_SHADER_PRESET), 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR ); }
static void frontend_qnx_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { unsigned i; char data_assets_path[PATH_MAX] = {0}; char assets_path[PATH_MAX] = {0}; char data_path[PATH_MAX] = {0}; char user_path[PATH_MAX] = {0}; char tmp_path[PATH_MAX] = {0}; char workdir[PATH_MAX] = {0}; getcwd(workdir, sizeof(workdir)); if(!string_is_empty(workdir)) { snprintf(assets_path, sizeof(data_path), "%s/app/native/assets", workdir); snprintf(data_path, sizeof(data_path), "%s/data", workdir); snprintf(user_path, sizeof(user_path), "%s/shared/misc/retroarch", workdir); snprintf(tmp_path, sizeof(user_path), "%s/tmp", workdir); } else { snprintf(assets_path, sizeof(data_path), "app/native/assets"); snprintf(data_path, sizeof(data_path), "data"); snprintf(user_path, sizeof(user_path), "shared/misc/retroarch"); snprintf(tmp_path, sizeof(user_path), "tmp"); } /* app data */ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], data_path, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], data_path, "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], data_path, "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], data_path, "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], data_path, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], data_path, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], data_path, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADERS], data_path, "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADERS])); /* user data */ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path, "content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], user_path, "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); fill_pathname_join(g_defaults.dirs[DEFAULT_VIDEO_FILTER], user_path, "filters/video", sizeof(g_defaults.dirs[DEFAULT_VIDEO_FILTER])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], user_path, "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], user_path, "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL], user_path, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS], user_path, "wallpapers", sizeof(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], user_path, "logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); /* tmp */ strlcpy(g_defaults.dirs[DEFAULT_DIR_CACHE], tmp_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); /* history and main config */ strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.path.config, user_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); /* bundle copy */ snprintf(data_assets_path, sizeof(data_assets_path), "%s/%s", data_path, "assets"); if (!filestream_exists(data_assets_path)) { char copy_command[PATH_MAX] = {0}; RARCH_LOG( "Copying application assets to data directory...\n" ); snprintf(copy_command, sizeof(copy_command), "cp -r %s/. %s", assets_path, data_path); if(system(copy_command) == -1) RARCH_LOG( "Asset copy failed: Shell could not be run.\n" ); else RARCH_LOG( "Asset copy successful.\n"); } for (i = 0; i < DEFAULT_DIR_LAST; i++) { const char *dir_path = g_defaults.dirs[i]; if (!string_is_empty(dir_path)) path_mkdir(dir_path); } /* set glui as default menu */ snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "glui"); }
/** * video_shader_parse_textures: * @conf : Preset file to read from. * @shader : Shader pass handle. * * Parses shader textures. * * Returns: true (1) if successful, otherwise false (0). **/ static bool video_shader_parse_textures(config_file_t *conf, struct video_shader *shader) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); const char *id = NULL; char *save = NULL; char *textures = (char*)malloc(1024 * sizeof(char)); textures[0] = '\0'; if (!config_get_array(conf, "textures", textures, 1024 * sizeof(char))) { free(textures); return true; } for (id = strtok_r(textures, ";", &save); id && shader->luts < GFX_MAX_TEXTURES; shader->luts++, id = strtok_r(NULL, ";", &save)) { char id_filter[64]; char id_wrap[64]; char wrap_mode[64]; char id_mipmap[64]; bool mipmap = false; bool smooth = false; char *tmp_path = NULL; id_filter[0] = id_wrap[0] = wrap_mode[0] = id_mipmap[0] = '\0'; if (!config_get_array(conf, id, shader->lut[shader->luts].path, sizeof(shader->lut[shader->luts].path))) { RARCH_ERR("Cannot find path to texture \"%s\" ...\n", id); free(textures); return false; } tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); tmp_path[0] = '\0'; strlcpy(tmp_path, shader->lut[shader->luts].path, path_size); path_resolve_realpath(tmp_path, path_size); if (filestream_exists(tmp_path)) strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); free(tmp_path); strlcpy(shader->lut[shader->luts].id, id, sizeof(shader->lut[shader->luts].id)); snprintf(id_filter, sizeof(id_filter), "%s_linear", id); if (config_get_bool(conf, id_filter, &smooth)) shader->lut[shader->luts].filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; else shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC; snprintf(id_wrap, sizeof(id_wrap), "%s_wrap_mode", id); if (config_get_array(conf, id_wrap, wrap_mode, sizeof(wrap_mode))) shader->lut[shader->luts].wrap = wrap_str_to_mode(wrap_mode); snprintf(id_mipmap, sizeof(id_mipmap), "%s_mipmap", id); if (config_get_bool(conf, id_mipmap, &mipmap)) shader->lut[shader->luts].mipmap = mipmap; else shader->lut[shader->luts].mipmap = false; } free(textures); return true; }
/** * video_shader_parse_pass: * @conf : Preset file to read from. * @pass : Shader passes handle. * @i : Index of shader pass. * * Parses shader pass from preset file. * * Returns: true (1) if successful, otherwise false (0). **/ static bool video_shader_parse_pass(config_file_t *conf, struct video_shader_pass *pass, unsigned i) { char shader_name[64]; char filter_name_buf[64]; char wrap_name_buf[64]; char wrap_mode[64]; char frame_count_mod_buf[64]; char srgb_output_buf[64]; char fp_fbo_buf[64]; char mipmap_buf[64]; char alias_buf[64]; char scale_name_buf[64]; char attr_name_buf[64]; char scale_type[64]; char scale_type_x[64]; char scale_type_y[64]; char frame_count_mod[64]; size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *tmp_path = NULL; struct gfx_fbo_scale *scale = NULL; bool tmp_bool = false; float fattr = 0.0f; int iattr = 0; fp_fbo_buf[0] = mipmap_buf[0] = alias_buf[0] = scale_name_buf[0] = attr_name_buf[0] = scale_type[0] = scale_type_x[0] = scale_type_y[0] = frame_count_mod[0] = tmp_str[0] = shader_name[0] = filter_name_buf[0] = wrap_name_buf[0] = wrap_mode[0] = frame_count_mod_buf[0] = '\0'; srgb_output_buf[0] = '\0'; /* Source */ snprintf(shader_name, sizeof(shader_name), "shader%u", i); if (!config_get_path(conf, shader_name, tmp_str, path_size)) { RARCH_ERR("Couldn't parse shader source (%s).\n", shader_name); goto error; } tmp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); strlcpy(tmp_path, tmp_str, path_size); path_resolve_realpath(tmp_path, path_size); if (!filestream_exists(tmp_path)) strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); else strlcpy(pass->source.path, tmp_path, sizeof(pass->source.path)); free(tmp_path); /* Smooth */ snprintf(filter_name_buf, sizeof(filter_name_buf), "filter_linear%u", i); if (config_get_bool(conf, filter_name_buf, &tmp_bool)) { bool smooth = tmp_bool; pass->filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; } else pass->filter = RARCH_FILTER_UNSPEC; /* Wrapping mode */ snprintf(wrap_name_buf, sizeof(wrap_name_buf), "wrap_mode%u", i); if (config_get_array(conf, wrap_name_buf, wrap_mode, sizeof(wrap_mode))) pass->wrap = wrap_str_to_mode(wrap_mode); /* Frame count mod */ snprintf(frame_count_mod_buf, sizeof(frame_count_mod_buf), "frame_count_mod%u", i); if (config_get_array(conf, frame_count_mod_buf, frame_count_mod, sizeof(frame_count_mod))) pass->frame_count_mod = (unsigned)strtoul(frame_count_mod, NULL, 0); /* FBO types and mipmapping */ snprintf(srgb_output_buf, sizeof(srgb_output_buf), "srgb_framebuffer%u", i); if (config_get_bool(conf, srgb_output_buf, &tmp_bool)) pass->fbo.srgb_fbo = tmp_bool; snprintf(fp_fbo_buf, sizeof(fp_fbo_buf), "float_framebuffer%u", i); if (config_get_bool(conf, fp_fbo_buf, &tmp_bool)) pass->fbo.fp_fbo = tmp_bool; snprintf(mipmap_buf, sizeof(mipmap_buf), "mipmap_input%u", i); if (config_get_bool(conf, mipmap_buf, &tmp_bool)) pass->mipmap = tmp_bool; snprintf(alias_buf, sizeof(alias_buf), "alias%u", i); if (!config_get_array(conf, alias_buf, pass->alias, sizeof(pass->alias))) *pass->alias = '\0'; /* Scale */ scale = &pass->fbo; snprintf(scale_name_buf, sizeof(scale_name_buf), "scale_type%u", i); config_get_array(conf, scale_name_buf, scale_type, sizeof(scale_type)); snprintf(scale_name_buf, sizeof(scale_name_buf), "scale_type_x%u", i); config_get_array(conf, scale_name_buf, scale_type_x, sizeof(scale_type_x)); snprintf(scale_name_buf, sizeof(scale_name_buf), "scale_type_y%u", i); config_get_array(conf, scale_name_buf, scale_type_y, sizeof(scale_type_y)); if (!*scale_type && !*scale_type_x && !*scale_type_y) { free(tmp_str); return true; } if (*scale_type) { strlcpy(scale_type_x, scale_type, sizeof(scale_type_x)); strlcpy(scale_type_y, scale_type, sizeof(scale_type_y)); } scale->valid = true; scale->type_x = RARCH_SCALE_INPUT; scale->type_y = RARCH_SCALE_INPUT; scale->scale_x = 1.0; scale->scale_y = 1.0; if (*scale_type_x) { if (string_is_equal(scale_type_x, "source")) scale->type_x = RARCH_SCALE_INPUT; else if (string_is_equal(scale_type_x, "viewport")) scale->type_x = RARCH_SCALE_VIEWPORT; else if (string_is_equal(scale_type_x, "absolute")) scale->type_x = RARCH_SCALE_ABSOLUTE; else { RARCH_ERR("Invalid attribute.\n"); goto error; } } if (*scale_type_y) { if (string_is_equal(scale_type_y, "source")) scale->type_y = RARCH_SCALE_INPUT; else if (string_is_equal(scale_type_y, "viewport")) scale->type_y = RARCH_SCALE_VIEWPORT; else if (string_is_equal(scale_type_y, "absolute")) scale->type_y = RARCH_SCALE_ABSOLUTE; else { RARCH_ERR("Invalid attribute.\n"); goto error; } } snprintf(attr_name_buf, sizeof(attr_name_buf), "scale%u", i); if (scale->type_x == RARCH_SCALE_ABSOLUTE) { if (config_get_int(conf, attr_name_buf, &iattr)) scale->abs_x = iattr; else { snprintf(attr_name_buf, sizeof(attr_name_buf), "scale_x%u", i); if (config_get_int(conf, attr_name_buf, &iattr)) scale->abs_x = iattr; } } else { if (config_get_float(conf, attr_name_buf, &fattr)) scale->scale_x = fattr; else { snprintf(attr_name_buf, sizeof(attr_name_buf), "scale_x%u", i); if (config_get_float(conf, attr_name_buf, &fattr)) scale->scale_x = fattr; } } snprintf(attr_name_buf, sizeof(attr_name_buf), "scale%u", i); if (scale->type_y == RARCH_SCALE_ABSOLUTE) { if (config_get_int(conf, attr_name_buf, &iattr)) scale->abs_y = iattr; else { snprintf(attr_name_buf, sizeof(attr_name_buf), "scale_y%u", i); if (config_get_int(conf, attr_name_buf, &iattr)) scale->abs_y = iattr; } } else { if (config_get_float(conf, attr_name_buf, &fattr)) scale->scale_y = fattr; else { snprintf(attr_name_buf, sizeof(attr_name_buf), "scale_y%u", i); if (config_get_float(conf, attr_name_buf, &fattr)) scale->scale_y = fattr; } } free(tmp_str); return true; error: free(tmp_str); return false; }