Mercurial > hg > dmlib
diff src/dmres.c @ 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 | fd1ccfc62ceb |
children | 043b5942fdb6 |
line wrap: on
line diff
--- 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);