(Wii) Use retro_read_file

This commit is contained in:
twinaphex 2015-09-19 12:34:52 +02:00
parent 6ca5145150
commit 57cf177286
1 changed files with 9 additions and 27 deletions

View File

@ -27,6 +27,7 @@
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#include <retro_log.h> #include <retro_log.h>
#include <retro_file.h>
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
@ -48,10 +49,9 @@ char gx_rom_path[PATH_MAX_LENGTH];
static void dol_copy_argv_path(const char *dolpath, const char *argpath) static void dol_copy_argv_path(const char *dolpath, const char *argpath)
{ {
char tmp[PATH_MAX_LENGTH]; char tmp[PATH_MAX_LENGTH];
size_t t_len; size_t t_len, len = 0;
struct __argv *argv = (struct __argv *)ARGS_ADDR; struct __argv *argv = (struct __argv *)ARGS_ADDR;
char *cmdline = NULL; char *cmdline = NULL;
size_t len = 0;
memset(ARGS_ADDR, 0, sizeof(struct __argv)); memset(ARGS_ADDR, 0, sizeof(struct __argv));
@ -115,11 +115,11 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath)
* heap memory and are restricted to the stack only. */ * heap memory and are restricted to the stack only. */
void system_exec_wii(const char *_path, bool should_load_game) void system_exec_wii(const char *_path, bool should_load_game)
{ {
FILE *fp; size_t booter_size;
size_t size, booter_size; ssize_t length;
void *dol;
char path[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH]; char game_path[PATH_MAX_LENGTH];
void *dol = NULL;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool original_verbose = global->verbosity; bool original_verbose = global->verbosity;
@ -139,30 +139,12 @@ void system_exec_wii(const char *_path, bool should_load_game)
} }
RARCH_LOG("Attempt to load executable: [%s]\n", path); RARCH_LOG("Attempt to load executable: [%s]\n", path);
if (retro_read_file(path, dol, &length) != 1)
fp = fopen(path, "rb");
if (fp == NULL)
{ {
RARCH_ERR("Could not open DOL file %s.\n", path); RARCH_ERR("Could not open DOL file %s.\n", path);
goto exit; goto exit;
} }
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
/* try to allocate a buffer for it. if we can't, fail. */
dol = malloc(size);
if (!dol)
{
RARCH_ERR("Could not execute DOL file %s.\n", path);
fclose(fp);
goto exit;
}
fread(dol, 1, size, fp);
fclose(fp);
fatUnmount("carda:"); fatUnmount("carda:");
fatUnmount("cardb:"); fatUnmount("cardb:");
fatUnmount("sd:"); fatUnmount("sd:");
@ -171,8 +153,8 @@ void system_exec_wii(const char *_path, bool should_load_game)
__io_usbstorage.shutdown(); __io_usbstorage.shutdown();
/* don't use memcpy, there might be an overlap. */ /* don't use memcpy, there might be an overlap. */
memmove(EXECUTE_ADDR, dol, size); memmove(EXECUTE_ADDR, dol, length);
DCFlushRange(EXECUTE_ADDR, size); DCFlushRange(EXECUTE_ADDR, length);
dol_copy_argv_path(path, should_load_game ? game_path : NULL); dol_copy_argv_path(path, should_load_game ? game_path : NULL);