fix to games stayed unzipped

This commit is contained in:
retro-wertz
2017-04-02 02:12:44 +08:00
parent 1486f36409
commit c58d035543

View File

@@ -63,7 +63,7 @@ doret:
return tmp; return tmp;
} }
static MEMWRAP *MakeMemWrapBuffer(void *tz, int type, uint8 *buffer, size_t bufsize) static MEMWRAP *MakeMemWrapBuffer(const char *tz, int type, uint8 *buffer, size_t bufsize)
{ {
MEMWRAP *tmp = (MEMWRAP*)FCEU_malloc(sizeof(MEMWRAP)); MEMWRAP *tmp = (MEMWRAP*)FCEU_malloc(sizeof(MEMWRAP));
@@ -81,20 +81,23 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn,
char *mode, char *ext, uint8 *buffer, size_t bufsize) char *mode, char *ext, uint8 *buffer, size_t bufsize)
{ {
FCEUFILE *fceufp = (FCEUFILE*)malloc(sizeof(FCEUFILE)); FCEUFILE *fceufp = (FCEUFILE*)malloc(sizeof(FCEUFILE));
void *t = fopen(path, mode);
if (!t)
{
free(fceufp);
return 0;
}
fseek((FILE*)t, 0, SEEK_SET);
fceufp->type = 0; fceufp->type = 0;
if (buffer) if (buffer)
fceufp->fp = MakeMemWrapBuffer(t, 0, buffer, bufsize); fceufp->fp = MakeMemWrapBuffer(path, 0, buffer, bufsize);
else else
{
void *t = fopen(path, mode);
if (!t)
{
free(fceufp);
return 0;
}
fseek((FILE*)t, 0, SEEK_SET);
fceufp->fp = MakeMemWrap(t, 0); fceufp->fp = MakeMemWrap(t, 0);
}
return fceufp; return fceufp;
} }