Take out most of the __LIBRETRO__ hacks in mainline codebase

This commit is contained in:
twinaphex
2014-04-18 19:22:25 +02:00
parent 216a88eda3
commit da7ac270f8
8 changed files with 0 additions and 78 deletions

View File

@@ -37,10 +37,6 @@
#include "driver.h"
#include "general.h"
#ifndef __LIBRETRO__
#define SUPPORTS_UNZIP_AND_GZIP
#endif
typedef struct {
uint8 *data;
uint32 size;
@@ -142,7 +138,6 @@ static MEMWRAP *MakeMemWrap(void *tz, int type) {
}
fread(tmp->data, 1, tmp->size, (FILE*)tz);
}
#ifdef SUPPORTS_UNZIP_AND_GZIP
else if (type == 1) {
/* Bleck. The gzip file format has the size of the uncompressed data,
but I can't get to the info with the zlib interface(?). */
@@ -166,20 +161,17 @@ static MEMWRAP *MakeMemWrap(void *tz, int type) {
}
unzReadCurrentFile(tz, tmp->data, ufo.uncompressed_size);
}
#endif
doret:
if (type == 0) {
fclose((FILE*)tz);
}
#ifdef SUPPORTS_UNZIP_AND_GZIP
else if (type == 1) {
gzclose(tz);
} else if (type == 2) {
unzCloseCurrentFile(tz);
unzClose(tz);
}
#endif
return tmp;
}
@@ -199,7 +191,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
fceufp = (FCEUFILE*)malloc(sizeof(FCEUFILE));
{
#ifdef SUPPORTS_UNZIP_AND_GZIP
unzFile tz;
if ((tz = unzOpen(path))) { // If it's not a zip file, use regular file handlers.
// Assuming file type by extension usually works,
@@ -286,7 +277,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
}
close(fd);
}
#endif
}
if ((t = FCEUD_UTF8fopen(path, mode))) {
@@ -309,7 +299,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
}
int FCEU_fclose(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
gzclose(fp->fp);
} else if (fp->type >= 2) {
@@ -318,7 +307,6 @@ int FCEU_fclose(FCEUFILE *fp) {
free(fp->fp);
fp->fp = 0;
} else
#endif
{
fclose((FILE*)fp->fp);
}
@@ -328,7 +316,6 @@ int FCEU_fclose(FCEUFILE *fp) {
}
uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gzread(fp->fp, ptr, size * nmemb);
} else if (fp->type >= 2) {
@@ -349,25 +336,21 @@ uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
return nmemb;
}
} else
#endif
{
return fread(ptr, size, nmemb, (FILE*)fp->fp);
}
}
uint64 FCEU_fwrite(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gzwrite(fp->fp, ptr, size * nmemb);
} else if (fp->type >= 2) {
return 0;
} else
#endif
return fwrite(ptr, size, nmemb, (FILE*)fp->fp);
}
int FCEU_fseek(FCEUFILE *fp, long offset, int whence) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return((gzseek(fp->fp, offset, whence) > 0) ? 0 : -1);
} else if (fp->type >= 2) {
@@ -385,29 +368,24 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence) {
}
return 0;
} else
#endif
return fseek((FILE*)fp->fp, offset, whence);
}
uint64 FCEU_ftell(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gztell(fp->fp);
} else if (fp->type >= 2) {
return(((MEMWRAP*)(fp->fp))->location);
} else
#endif
return ftell((FILE*)fp->fp);
}
void FCEU_rewind(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
gzrewind(fp->fp);
} else if (fp->type >= 2) {
((MEMWRAP*)(fp->fp))->location = 0;
} else
#endif
/* Rewind */
fseek(fp->fp, 0, SEEK_SET);
}
@@ -415,7 +393,6 @@ void FCEU_rewind(FCEUFILE *fp) {
int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
uint8 t[2];
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type >= 1) {
if (fp->type >= 2) {
MEMWRAP *wz;
@@ -429,7 +406,6 @@ int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
if (gzread(fp->fp, &t, 2) != 2) return(0);
return(1);
} else
#endif
{
if (fread(t, 1, 2, (FILE*)fp->fp) != 2) return(0);
}
@@ -438,7 +414,6 @@ int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
}
int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type >= 1) {
uint8 t[4];
#ifndef LSB_FIRST
@@ -465,14 +440,12 @@ int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
#endif
return 1;
} else
#endif
{
return read32le(Bufo, (FILE*)fp->fp);
}
}
int FCEU_fgetc(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1)
return gzgetc(fp->fp);
else if (fp->type >= 2) {
@@ -482,12 +455,10 @@ int FCEU_fgetc(FCEUFILE *fp) {
return wz->data[wz->location++];
return EOF;
} else
#endif
return fgetc((FILE*)fp->fp);
}
uint64 FCEU_fgetsize(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
int x, t;
t = gztell(fp->fp);
@@ -498,7 +469,6 @@ uint64 FCEU_fgetsize(FCEUFILE *fp) {
} else if (fp->type >= 2)
return ((MEMWRAP*)(fp->fp))->size;
else
#endif
{
long t, r;
t = ftell((FILE*)fp->fp);
@@ -510,9 +480,7 @@ uint64 FCEU_fgetsize(FCEUFILE *fp) {
}
int FCEU_fisarchive(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 2)
return 1;
#endif
return 0;
}