Mercurial > hg > dmlib
changeset 1106:f8e9f6b2a41a
Hmm .. back out the Sint64 changes for now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 04 Mar 2015 00:40:15 +0200 |
parents | 62ccecea1317 |
children | 69c0d8ad2672 |
files | src/dmlib.h src/dmres.c src/dmres.h |
diffstat | 3 files changed, 18 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmlib.h Wed Mar 04 00:00:11 2015 +0200 +++ b/src/dmlib.h Wed Mar 04 00:40:15 2015 +0200 @@ -78,17 +78,6 @@ #define DMRES_RES_FILE "res.txt" // Resource data file -/* File operations - */ -#ifdef HAVE_FSEEK64 -# define DM_FSEEK64 fseek64 -# define DM_FTELL64 ftell64 -#else -# define DM_FSEEK64 fseeko -# define DM_FTELL64 ftello -#endif - - /* Define a boolean type */ #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
--- a/src/dmres.c Wed Mar 04 00:00:11 2015 +0200 +++ b/src/dmres.c Wed Mar 04 00:40:15 2015 +0200 @@ -172,15 +172,15 @@ } -static Sint64 dm_stdio_ftell(DMResource * f) +static off_t dm_stdio_ftell(DMResource * f) { - return DM_FTELL64(f->fh); + return ftello(f->fh); } -static int dm_stdio_fseek(DMResource *f, const Sint64 pos, const int whence) +static int dm_stdio_fseek(DMResource *f, const off_t pos, const int whence) { - int ret = DM_FSEEK64(f->fh, pos, whence); + int ret = fseeko(f->fh, pos, whence); f->error = dmGetErrno(); return ret; } @@ -204,11 +204,15 @@ return f->rawSize; // Get file size - savePos = dm_stdio_ftell(f); + if ((savePos = dm_stdio_ftell(f)) < 0) + return -1; + if (dm_stdio_fseek(f, 0, SEEK_END) != 0) return -1; - fileSize = dm_stdio_ftell(f); + if ((fileSize = dm_stdio_ftell(f)) < 0) + return -1; + if (dm_stdio_fseek(f, savePos, SEEK_SET) != 0) return -1; @@ -449,7 +453,7 @@ } // Seek to entry - if (DM_FSEEK64(handle->lib->packFile->file, node->offset, SEEK_SET) != 0) + if (fseeko(handle->lib->packFile->file, node->offset, SEEK_SET) != 0) { ret = dmErrorDBG(DMERR_FSEEK, "Could not seek node position in PACK file.\n"); @@ -537,7 +541,7 @@ } -static int dm_mem_fseek(DMResource * f, const Sint64 offset, const int whence) +static int dm_mem_fseek(DMResource * f, const off_t offset, const int whence) { off_t newPos; @@ -577,7 +581,7 @@ } -static Sint64 dm_mem_ftell(DMResource * f) +static off_t dm_mem_ftell(DMResource * f) { return f->rawOffset; } @@ -886,7 +890,7 @@ return f->fops->ferror(f); } -int dmfseek(DMResource * f, Sint64 offset, int whence) +int dmfseek(DMResource * f, const off_t offset, int whence) { f->atime = time(NULL); return f->fops->fseek(f, offset, whence);
--- a/src/dmres.h Wed Mar 04 00:00:11 2015 +0200 +++ b/src/dmres.h Wed Mar 04 00:40:15 2015 +0200 @@ -115,9 +115,9 @@ int (*freset)(DMResource *); int (*ferror)(DMResource *); - int (*fseek)(DMResource *, const Sint64, const int); + int (*fseek)(DMResource *, const off_t, const int); off_t (*fsize)(DMResource *); - Sint64 (*ftell)(DMResource *); + off_t (*ftell)(DMResource *); BOOL (*feof)(DMResource *); int (*fgetc)(DMResource *); int (*fputc)(int, DMResource *); @@ -161,9 +161,9 @@ // Basic resource access functions int dmfreset(DMResource *); int dmferror(DMResource *); -int dmfseek(DMResource *, Sint64, const int); +int dmfseek(DMResource *, const off_t, const int); off_t dmfsize(DMResource *); -Sint64 dmftell(DMResource *); +off_t dmftell(DMResource *); BOOL dmfeof(DMResource *); int dmfgetc(DMResource *); int dmfputc(int, DMResource *);