summaryrefslogtreecommitdiff
path: root/source/fitz/stream-open.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-05-14 17:12:42 +0100
committerRobin Watts <robin.watts@artifex.com>2015-05-15 13:06:56 +0100
commit7d5ff30c37c9e5b271fdb2b8cb3219068048322e (patch)
tree5f60d1d03235f2cff161207e00515c5a4a69ef73 /source/fitz/stream-open.c
parent250e8a11e1debfbd9c4fc84ad895bf923aac135e (diff)
downloadmupdf-7d5ff30c37c9e5b271fdb2b8cb3219068048322e.tar.xz
Support pdf files larger than 2Gig.
If FZ_LARGEFILE is defined when building, MuPDF uses 64bit offsets for files; this allows us to open streams larger than 2Gig. The downsides to this are that: * The xref entries are larger. * All PDF ints are held as 64bit things rather than 32bit things (to cope with /Prev entries, hint stream offsets etc). * All file positions are stored as 64bits rather than 32. The implementation works by detecting FZ_LARGEFILE. Some #ifdeffery in fitz/system.h sets fz_off_t to either int or int64_t as appropriate, and sets defines for fz_fopen, fz_fseek, fz_ftell etc as required. These call the fseeko64 etc functions on linux (and so define _LARGEFILE64_SOURCE) and the explicit 64bit functions on windows.
Diffstat (limited to 'source/fitz/stream-open.c')
-rw-r--r--source/fitz/stream-open.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c
index 10d94a09..4a3b69ad 100644
--- a/source/fitz/stream-open.c
+++ b/source/fitz/stream-open.c
@@ -81,13 +81,13 @@ static int next_file(fz_context *ctx, fz_stream *stm, int n)
return *stm->rp++;
}
-static void seek_file(fz_context *ctx, fz_stream *stm, int offset, int whence)
+static void seek_file(fz_context *ctx, fz_stream *stm, fz_off_t offset, int whence)
{
fz_file_stream *state = stm->state;
- int n = fseek(state->file, offset, whence);
+ fz_off_t n = fz_fseek(state->file, offset, whence);
if (n < 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot seek: %s", strerror(errno));
- stm->pos = ftell(state->file);
+ stm->pos = fz_ftell(state->file);
stm->rp = state->buffer;
stm->wp = state->buffer;
}
@@ -139,7 +139,7 @@ fz_open_file(fz_context *ctx, const char *name)
f = _wfopen(wname, L"rb");
fz_free(ctx, wname);
#else
- f = fopen(name, "rb");
+ f = fz_fopen(name, "rb");
#endif
if (f == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open %s", name);
@@ -164,9 +164,9 @@ static int next_buffer(fz_context *ctx, fz_stream *stm, int max)
return EOF;
}
-static void seek_buffer(fz_context *ctx, fz_stream *stm, int offset, int whence)
+static void seek_buffer(fz_context *ctx, fz_stream *stm, fz_off_t offset, int whence)
{
- int pos = stm->pos - (stm->wp - stm->rp);
+ fz_off_t pos = stm->pos - (stm->wp - stm->rp);
/* Convert to absolute pos */
if (whence == 1)
{
@@ -181,7 +181,7 @@ static void seek_buffer(fz_context *ctx, fz_stream *stm, int offset, int whence)
offset = 0;
if (offset > stm->pos)
offset = stm->pos;
- stm->rp += offset - pos;
+ stm->rp += (int)(offset - pos);
}
static void close_buffer(fz_context *ctx, void *state_)