/* Load the content into memory. */ static bool load_content_into_memory( struct retro_game_info *info, unsigned i, const char *path) { ssize_t len; bool ret = false; if (i == 0) { /* First content file is significant, attempt to do patching, * CRC checking, etc. */ ret = read_content_file(i, path, (void**)&info->data, &len); } else ret = content_file_read(path, (void**)&info->data, &len); if (!ret || len < 0) goto error; info->size = len; return true; error: RARCH_ERR("%s \"%s\".\n", msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE), path); return false; }
static bool load_content_dont_need_fullpath( struct retro_game_info *info, unsigned i, const char *path) { ssize_t len; /* Load the content into memory. */ /* First content file is significant, attempt to do patching, * CRC checking, etc. */ bool ret = false; if (i == 0) ret = read_content_file(i, path, (void**)&info->data, &len); else ret = read_file(path, (void**)&info->data, &len); if (!ret || len < 0) { RARCH_ERR("%s \"%s\".\n", msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE), path); return false; } info->size = len; return true; }
static bool load_content(const struct retro_subsystem_info *special, const struct string_list *content) { unsigned i; bool ret = true; struct retro_game_info *info = (struct retro_game_info*)calloc(content->size, sizeof(*info)); if (!info) 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 = *path ? path : NULL; if (!need_fullpath && *path) // Load the content into memory. { RARCH_LOG("Loading content file: %s.\n", path); // First content file is significant, attempt to do patching, CRC checking, etc ... long size = i == 0 ? read_content_file(path, (void**)&info[i].data) : read_file(path, (void**)&info[i].data); if (size < 0) { RARCH_ERR("Could not read content file \"%s\".\n", path); ret = false; goto end; } info[i].size = size; } else RARCH_LOG("Content loading skipped. Implementation will load it on its own.\n"); } if (special) ret = pretro_load_game_special(special->id, info, content->size); else ret = pretro_load_game(*content->elems[0].data ? info : NULL); if (!ret) RARCH_ERR("Failed to load game.\n"); end: for (i = 0; i < content->size; i++) free((void*)info[i].data); free(info); return ret; }
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) 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 = *path ? path : NULL; if (!need_fullpath && *path) { /* Load the content into memory. */ RARCH_LOG("Loading content file: %s.\n", path); /* First content file is significant, attempt to do patching, * CRC checking, etc. */ long size = i == 0 ? read_content_file(path, (void**)&info[i].data) : read_file(path, (void**)&info[i].data); if (size < 0) { RARCH_ERR("Could not read content file \"%s\".\n", path); ret = false; goto end; } info[i].size = size; } else { RARCH_LOG("Content loading skipped. Implementation will" " load it on its own.\n"); if (need_fullpath && path_contains_compressed_file(path)) { RARCH_LOG("Compressed file in case of need_fullpath." "Now extracting to temporary directory.\n"); if ((!strcmp(g_settings.extraction_directory,"")) || !path_is_directory(g_settings.extraction_directory)) { RARCH_ERR("Tried extracting to extraction directory, but " "extraction directory was not set or found. Exiting.\n"); rarch_assert(false); } char new_path[PATH_MAX]; union string_list_elem_attr attr; attr.i = 0; fill_pathname_join(new_path,g_settings.extraction_directory, path_basename(path),sizeof(new_path)); read_compressed_file(path,NULL,new_path); string_list_append(additional_path_allocs,new_path,attr); info[i].path = additional_path_allocs->elems [additional_path_allocs->size -1 ].data; } } } if (special) ret = pretro_load_game_special(special->id, info, content->size); else ret = pretro_load_game(*content->elems[0].data ? info : NULL); if (!ret) RARCH_ERR("Failed to load game.\n"); end: for (i = 0; i < content->size; i++) free((void*)info[i].data); string_list_free(additional_path_allocs); free(info); return ret; }