/** * load_content: * @special : subsystem of content to be loaded. Can be NULL. * content : * * Load content file (for libretro core). * * Returns : true if successful, otherwise false. **/ static bool load_content(const struct retro_subsystem_info *special, const struct string_list *content) { unsigned i; bool ret = true; const char* json = NULL; struct string_list* additional_path_allocs = string_list_new(); struct retro_game_info *info = (struct retro_game_info*) calloc(content->size, sizeof(*info)); if (!info) { string_list_free(additional_path_allocs); return false; } for (i = 0; i < content->size; i++) { const char *path = content->elems[i].data; int attr = content->elems[i].attr.i; bool need_fullpath = attr & 2; bool require_content = attr & 4; if (require_content && !*path) { RARCH_LOG("libretro core requires content, but nothing was provided.\n"); ret = false; goto end; } info[i].path = NULL; if (*path) info[i].path = path; if (!need_fullpath && *path) { if (!load_content_dont_need_fullpath(&info[i], i, path)) goto end; } else { RARCH_LOG("Content loading skipped. Implementation will" " load it on its own.\n"); if (!load_content_need_fullpath(&info[i], i, additional_path_allocs, need_fullpath, path)) goto end; } } if (special) ret = core.retro_load_game_special(special->id, info, content->size); else { if (*content->elems[0].data) { if ( cheevos_get_by_content(&json, info->data, info->size) == 0 ) { cheevos_load(json); free((void*)json); } } ret = core.retro_load_game(*content->elems[0].data ? info : NULL); } if (!ret) RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT)); end: for (i = 0; i < content->size; i++) free((void*)info[i].data); string_list_free(additional_path_allocs); if (info) free(info); return ret; }
/** * load_content: * @special : subsystem of content to be loaded. Can be NULL. * content : * * Load content file (for libretro core). * * Returns : true if successful, otherwise false. **/ static bool load_content( struct string_list *temporary_content, struct retro_game_info *info, const struct string_list *content, const struct retro_subsystem_info *special, struct string_list* additional_path_allocs ) { unsigned i; retro_ctx_load_content_info_t load_info; if (!info || !additional_path_allocs) return false; for (i = 0; i < content->size; i++) { int attr = content->elems[i].attr.i; bool need_fullpath = attr & 2; bool require_content = attr & 4; const char *path = content->elems[i].data; if (require_content && string_is_empty(path)) { RARCH_LOG("libretro core requires content, " "but nothing was provided.\n"); return false; } info[i].path = NULL; if (*path) info[i].path = path; if (!need_fullpath && !string_is_empty(path)) { if (!load_content_into_memory(&info[i], i, path)) return false; } else { RARCH_LOG("Content loading skipped. Implementation will" " load it on its own.\n"); #ifdef HAVE_COMPRESSION if (!load_content_from_compressed_archive( temporary_content, &info[i], i, additional_path_allocs, need_fullpath, path)) return false; #endif } } load_info.content = content; load_info.special = special; load_info.info = info; if (!core_load_game(&load_info)) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT)); return false; } #ifdef HAVE_CHEEVOS if (!special) { const void *load_data = NULL; cheevos_set_cheats(); if (*content->elems[0].data) load_data = info; cheevos_load(load_data); } #endif return true; }
/** * content_file_load: * @special : subsystem of content to be loaded. Can be NULL. * content : * * Load content file (for libretro core). * * Returns : true if successful, otherwise false. **/ static bool content_file_load( struct retro_game_info *info, const struct string_list *content, content_information_ctx_t *content_ctx, char **error_string, const struct retro_subsystem_info *special ) { unsigned i; retro_ctx_load_content_info_t load_info; char msg[1024]; struct string_list *additional_path_allocs = string_list_new(); msg[0] = '\0'; if (!additional_path_allocs) return false; for (i = 0; i < content->size; i++) { int attr = content->elems[i].attr.i; const char *path = content->elems[i].data; bool need_fullpath = attr & 2; bool require_content = attr & 4; if (require_content && string_is_empty(path)) { snprintf(msg, sizeof(msg), "%s\n", msg_hash_to_str(MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT)); *error_string = strdup(msg); goto error; } info[i].path = NULL; if (!string_is_empty(path)) info[i].path = path; if (!need_fullpath && !string_is_empty(path)) { /* Load the content into memory. */ ssize_t len = 0; if (!load_content_into_memory(i, path, (void**)&info[i].data, &len)) { snprintf(msg, sizeof(msg), "%s \"%s\".\n", msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE), path); *error_string = strdup(msg); goto error; } info[i].size = len; } else { RARCH_LOG("%s\n", msg_hash_to_str( MSG_CONTENT_LOADING_SKIPPED_IMPLEMENTATION_WILL_DO_IT)); #ifdef HAVE_COMPRESSION if ( !content_ctx->block_extract && need_fullpath && path_contains_compressed_file(path) && !load_content_from_compressed_archive( content_ctx, &info[i], i, additional_path_allocs, need_fullpath, path, error_string)) goto error; #endif } } load_info.content = content; load_info.special = special; load_info.info = info; if (!core_load_game(&load_info)) { snprintf(msg, sizeof(msg), "%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT)); *error_string = strdup(msg); goto error; } #ifdef HAVE_CHEEVOS if (!special) { const void *load_data = NULL; const char *path = content->elems[0].data; cheevos_set_cheats(); if (!string_is_empty(path)) load_data = info; cheevos_load(load_data); } #endif string_list_free(additional_path_allocs); return true; error: if (additional_path_allocs) string_list_free(additional_path_allocs); return false; }
/** * load_content: * @special : subsystem of content to be loaded. Can be NULL. * content : * * Load content file (for libretro core). * * Returns : true if successful, otherwise false. **/ static bool load_content(const struct retro_subsystem_info *special, const struct string_list *content) { unsigned i; bool ret = true; struct string_list* additional_path_allocs = string_list_new(); struct retro_game_info *info = (struct retro_game_info*) calloc(content->size, sizeof(*info)); if (!info) { string_list_free(additional_path_allocs); return false; } for (i = 0; i < content->size; i++) { const char *path = content->elems[i].data; int attr = content->elems[i].attr.i; bool need_fullpath = attr & 2; bool require_content = attr & 4; if (require_content && !*path) { RARCH_LOG("libretro core requires content, but nothing was provided.\n"); ret = false; goto end; } info[i].path = NULL; if (*path) info[i].path = path; if (!need_fullpath && *path) { if (!load_content_dont_need_fullpath(&info[i], i, path)) goto end; } else { RARCH_LOG("Content loading skipped. Implementation will" " load it on its own.\n"); if (!load_content_need_fullpath(&info[i], i, additional_path_allocs, need_fullpath, path)) goto end; } } if (special) ret = core.retro_load_game_special(special->id, info, content->size); else { ret = core.retro_load_game(*content->elems[0].data ? info : NULL); #ifdef HAVE_CHEEVOS /* Load the achievements into memory if the game has content. */ cheevos_globals.cheats_were_enabled = cheevos_globals.cheats_are_enabled; cheevos_load(*content->elems[0].data ? info : NULL); #endif } if (!ret) RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT)); end: for (i = 0; i < content->size; i++) free((void*)info[i].data); string_list_free(additional_path_allocs); if (info) free(info); return ret; }