mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-04 00:06:11 +00:00
(PS3) ZIP files can now be unzipped - if you press X on a ZIP file
in the file browser, it will extract the contents to the /dev_hdd1 partition. You can then start the ROM from there. (problem right now - savestates/SRAM get saved to this swap partition too - which we flush at SSNES exit)
This commit is contained in:
parent
f61348e53f
commit
9708536cd8
@ -84,7 +84,7 @@ endif
|
||||
|
||||
PPU_LDLIBS = -ldbgfont $(GL_LIBS) -lcgc -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread -lsnes
|
||||
|
||||
DEFINES += -DSSNES_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_RSOUND -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DPACKAGE_VERSION=\"$(SSNES_VERSION)\" -DHAVE_SCREENSHOTS_BUILTIN=1 -Dmain=ssnes_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
DEFINES += -DSSNES_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DPACKAGE_VERSION=\"$(SSNES_VERSION)\" -DHAVE_SCREENSHOTS_BUILTIN=1 -Dmain=ssnes_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
PPU_OPTIMIZE_LV := -O0 -g
|
||||
|
@ -25,6 +25,12 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include "szlib/zlib.h"
|
||||
|
||||
#define WRITEBUFFERSIZE (512192)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../posix_string.h"
|
||||
#endif
|
||||
@ -95,3 +101,127 @@ void ssnes_console_set_default_keybind_names_for_emulator (void)
|
||||
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_SELECT], "Mode button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_SELECT]));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
static int ssnes_extract_currentfile_in_zip(unzFile uf)
|
||||
{
|
||||
char filename_inzip[256];
|
||||
int err=UNZ_OK;
|
||||
FILE *fout=NULL;
|
||||
void* buf;
|
||||
unsigned int size_buf;
|
||||
|
||||
unz_file_info file_info;
|
||||
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
SSNES_ERR("error %d with zipfile in unzGetCurrentFileInfo\n",err);
|
||||
return err;
|
||||
}
|
||||
|
||||
size_buf = WRITEBUFFERSIZE;
|
||||
buf = (void*)malloc(size_buf);
|
||||
if (buf==NULL)
|
||||
{
|
||||
SSNES_ERR("Error allocating memory\n");
|
||||
return UNZ_INTERNALERROR;
|
||||
}
|
||||
|
||||
char write_filename[1024];
|
||||
|
||||
/* TODO: currently hardcoded for PS3, fix this */
|
||||
snprintf(write_filename, sizeof(write_filename), "/dev_hdd1/%s", filename_inzip);
|
||||
|
||||
err = unzOpenCurrentFile(uf);
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
/* failure */
|
||||
SSNES_ERR("error %d with zipfile in unzOpenCurrentFile\n",err);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* success */
|
||||
fout=fopen(write_filename,"wb");
|
||||
|
||||
if (fout==NULL)
|
||||
{
|
||||
SSNES_ERR("error opening %s\n",write_filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (fout!=NULL)
|
||||
{
|
||||
SSNES_LOG(" extracting: %s\n",write_filename);
|
||||
|
||||
do
|
||||
{
|
||||
err = unzReadCurrentFile(uf,buf,size_buf);
|
||||
if (err<0)
|
||||
{
|
||||
SSNES_ERR("error %d with zipfile in unzReadCurrentFile\n",err);
|
||||
break;
|
||||
}
|
||||
if (err>0)
|
||||
if (fwrite(buf,err,1,fout)!=1)
|
||||
{
|
||||
SSNES_ERR("error in writing extracted file\n");
|
||||
err=UNZ_ERRNO;
|
||||
break;
|
||||
}
|
||||
}while (err>0);
|
||||
|
||||
if (fout)
|
||||
fclose(fout);
|
||||
|
||||
}
|
||||
|
||||
if (err==UNZ_OK)
|
||||
{
|
||||
err = unzCloseCurrentFile (uf);
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
SSNES_ERR("error %d with zipfile in unzCloseCurrentFile\n",err);
|
||||
}
|
||||
}
|
||||
else
|
||||
unzCloseCurrentFile(uf);
|
||||
|
||||
free(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
int ssnes_extract_zipfile(const char * zip_path)
|
||||
{
|
||||
unsigned long i;
|
||||
unz_global_info gi;
|
||||
int err;
|
||||
unzFile uf;
|
||||
|
||||
uf = unzOpen(zip_path);
|
||||
|
||||
err = unzGetGlobalInfo(uf,&gi);
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
SSNES_ERR("error %d with zipfile in unzGetGlobalInfo \n",err);
|
||||
}
|
||||
|
||||
for (i = 0; i < gi.number_entry; i++)
|
||||
{
|
||||
if (ssnes_extract_currentfile_in_zip(uf) != UNZ_OK)
|
||||
break;
|
||||
|
||||
if ((i+1)<gi.number_entry)
|
||||
{
|
||||
err = unzGoToNextFile(uf);
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
SSNES_ERR("error %d with zipfile in unzGoToNextFile\n",err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -32,4 +32,8 @@ void ssnes_console_name_from_id(char *name, size_t size);
|
||||
// will need different keybind names for buttons, etc.)
|
||||
void ssnes_console_set_default_keybind_names_for_emulator(void);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
int ssnes_extract_zipfile(const char * zip_path);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
13
ps3/menu.c
13
ps3/menu.c
@ -2001,10 +2001,15 @@ static void select_rom(void)
|
||||
|
||||
snprintf(rom_path_temp, sizeof(rom_path_temp), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), FILEBROWSER_GET_CURRENT_FILENAME(browser));
|
||||
|
||||
g_console.menu_enable = false;
|
||||
snprintf(g_console.rom_path, sizeof(g_console.rom_path), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), FILEBROWSER_GET_CURRENT_FILENAME(browser));
|
||||
g_console.initialize_ssnes_enable = 1;
|
||||
g_console.mode_switch = MODE_EMULATION;
|
||||
if(strstr(rom_path_temp, ".zip") || strstr(rom_path_temp, ".ZIP"))
|
||||
ssnes_extract_zipfile(rom_path_temp);
|
||||
else
|
||||
{
|
||||
g_console.menu_enable = false;
|
||||
snprintf(g_console.rom_path, sizeof(g_console.rom_path), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), FILEBROWSER_GET_CURRENT_FILENAME(browser));
|
||||
g_console.initialize_ssnes_enable = 1;
|
||||
g_console.mode_switch = MODE_EMULATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user