Commit a3cee0e7 authored by Adrian Johnson's avatar Adrian Johnson

Large file support

Create a Goffset type and use this type for all file offsets and file
sizes.

Bug 44085
parent 6eebbb9c
......@@ -28,7 +28,7 @@
using namespace poppler;
void detail::error_function(void * /*data*/, ErrorCategory /*category*/, int pos, char *msg)
void detail::error_function(void * /*data*/, ErrorCategory /*category*/, Goffset pos, char *msg)
{
std::ostringstream oss;
if (pos >= 0) {
......
......@@ -38,7 +38,7 @@ namespace poppler
namespace detail
{
void error_function(void *data, ErrorCategory category, int pos, char *msg);
void error_function(void *data, ErrorCategory category, Goffset pos, char *msg);
rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect);
......
......@@ -21,7 +21,7 @@
#include "poppler-input-stream.h"
PopplerInputStream::PopplerInputStream(GInputStream *inputStreamA, GCancellable *cancellableA,
Guint startA, GBool limitedA, Guint lengthA, Object *dictA)
Goffset startA, GBool limitedA, Goffset lengthA, Object *dictA)
: BaseStream(dictA, lengthA)
{
inputStream = (GInputStream *)g_object_ref(inputStreamA);
......@@ -45,8 +45,8 @@ BaseStream *PopplerInputStream::copy() {
return new PopplerInputStream(inputStream, cancellable, start, limited, length, &dict);
}
Stream *PopplerInputStream::makeSubStream(Guint startA, GBool limitedA,
Guint lengthA, Object *dictA)
Stream *PopplerInputStream::makeSubStream(Goffset startA, GBool limitedA,
Goffset lengthA, Object *dictA)
{
return new PopplerInputStream(inputStream, cancellable, startA, limitedA, lengthA, dictA);
}
......@@ -70,7 +70,7 @@ void PopplerInputStream::close()
saved = gFalse;
}
void PopplerInputStream::setPos(Guint pos, int dir)
void PopplerInputStream::setPos(Goffset pos, int dir)
{
Guint size;
GSeekable *seekable = G_SEEKABLE(inputStream);
......@@ -90,7 +90,7 @@ void PopplerInputStream::setPos(Guint pos, int dir)
bufPtr = bufEnd = buf;
}
void PopplerInputStream::moveStart(int delta)
void PopplerInputStream::moveStart(Goffset delta)
{
start += delta;
bufPtr = bufEnd = buf;
......
......@@ -31,11 +31,11 @@ class PopplerInputStream: public BaseStream {
public:
PopplerInputStream(GInputStream *inputStream, GCancellable *cancellableA,
Guint startA, GBool limitedA, Guint lengthA, Object *dictA);
Goffset startA, GBool limitedA, Goffset lengthA, Object *dictA);
virtual ~PopplerInputStream();
virtual BaseStream *copy();
virtual Stream *makeSubStream(Guint start, GBool limited,
Guint lengthA, Object *dictA);
virtual Stream *makeSubStream(Goffset start, GBool limited,
Goffset lengthA, Object *dictA);
virtual StreamKind getKind() { return strWeird; }
virtual void reset();
virtual void close();
......@@ -43,10 +43,10 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual int getPos() { return bufPos + (bufPtr - buf); }
virtual void setPos(Guint pos, int dir = 0);
virtual Guint getStart() { return start; }
virtual void moveStart(int delta);
virtual Goffset getPos() { return bufPos + (bufPtr - buf); }
virtual void setPos(Goffset pos, int dir = 0);
virtual Goffset getStart() { return start; }
virtual void moveStart(Goffset delta);
virtual int getUnfilteredChar() { return getChar(); }
virtual void unfilteredReset() { reset(); }
......@@ -60,7 +60,7 @@ private:
GInputStream *inputStream;
GCancellable *cancellable;
Guint start;
Goffset start;
GBool limited;
char buf[inputStreamBufSize];
char *bufPtr;
......
......@@ -24,6 +24,9 @@
#ifndef GTYPES_H
#define GTYPES_H
#include "poppler-config.h"
#include <stdio.h> // for off_t
/*
* These have stupid names to avoid conflicts with some (but not all)
* C++ compilers which define them.
......@@ -45,4 +48,16 @@ typedef unsigned short Gushort;
typedef unsigned int Guint;
typedef unsigned long Gulong;
/* Define Goffset to be the offset type used by the version of
* fseek we are using.
*/
#if HAVE_FSEEKO
typedef off_t Goffset;
#elif HAVE_FSEEK64
typedef off64_t Goffset;
#else
typedef long Goffset;
#endif
#endif
......@@ -341,7 +341,7 @@ void BaseCryptStream::reset() {
str->reset();
}
int BaseCryptStream::getPos() {
Goffset BaseCryptStream::getPos() {
return charactersRead;
}
......
......@@ -107,7 +107,7 @@ public:
virtual void reset();
virtual int getChar();
virtual int lookChar() = 0;
virtual int getPos();
virtual Goffset getPos();
virtual GBool isBinary(GBool last);
virtual Stream *getUndecodedStream() { return this; }
void setAutoDelete(GBool val);
......
......@@ -48,17 +48,17 @@ static const char *errorCategoryNames[] = {
};
static void (*errorCbk)(void *data, ErrorCategory category,
int pos, char *msg) = NULL;
Goffset pos, char *msg) = NULL;
static void *errorCbkData = NULL;
void setErrorCallback(void (*cbk)(void *data, ErrorCategory category,
int pos, char *msg),
Goffset pos, char *msg),
void *data) {
errorCbk = cbk;
errorCbkData = data;
}
void CDECL error(ErrorCategory category, int pos, const char *msg, ...) {
void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...) {
va_list args;
GooString *s, *sanitized;
......@@ -84,8 +84,8 @@ void CDECL error(ErrorCategory category, int pos, const char *msg, ...) {
(*errorCbk)(errorCbkData, category, pos, sanitized->getCString());
} else {
if (pos >= 0) {
fprintf(stderr, "%s (%d): %s\n",
errorCategoryNames[category], pos, sanitized->getCString());
fprintf(stderr, "%s (%lld): %s\n",
errorCategoryNames[category], (long long)pos, sanitized->getCString());
} else {
fprintf(stderr, "%s: %s\n",
errorCategoryNames[category], sanitized->getCString());
......
......@@ -31,6 +31,7 @@
#include <stdarg.h>
#include "poppler-config.h"
#include "goo/gtypes.h"
enum ErrorCategory {
errSyntaxWarning, // PDF syntax error which can be worked around;
......@@ -48,9 +49,9 @@ enum ErrorCategory {
};
extern void setErrorCallback(void (*cbk)(void *data, ErrorCategory category,
int pos, char *msg),
Goffset pos, char *msg),
void *data);
extern void CDECL error(ErrorCategory category, int pos, const char *msg, ...);
extern void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...);
#endif
......@@ -51,7 +51,7 @@ Hints::Hints(BaseStream *str, Linearization *linearization, XRef *xref, Security
pageObjectNum = (int *) gmallocn_checkoverflow(nPages, sizeof(int));
xRefOffset = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
pageLength = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
pageOffset = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
pageOffset = (Goffset *) gmallocn_checkoverflow(nPages, sizeof(Goffset));
numSharedObject = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
sharedObjectId = (Guint **) gmallocn_checkoverflow(nPages, sizeof(Guint*));
if (!nObjects || !pageObjectNum || !xRefOffset || !pageLength || !pageOffset ||
......@@ -344,7 +344,7 @@ void Hints::readSharedObjectsTable(Stream *str)
}
}
Guint Hints::getPageOffset(int page)
Goffset Hints::getPageOffset(int page)
{
if ((page < 1) || (page > nPages)) return 0;
......
......@@ -33,7 +33,7 @@ public:
~Hints();
int getPageObjectNum(int page);
Guint getPageOffset(int page);
Goffset getPageOffset(int page);
std::vector<ByteRange>* getPageRanges(int page);
private:
......@@ -54,7 +54,7 @@ private:
int nPages;
int pageFirst;
int pageObjectFirst;
Guint pageOffsetFirst;
Goffset pageOffsetFirst;
Guint pageEndFirst;
int objectNumberFirst;
......@@ -76,7 +76,7 @@ private:
int *pageObjectNum;
Guint *xRefOffset;
Guint *pageLength;
Guint *pageOffset;
Goffset *pageOffset;
Guint *numSharedObject;
Guint **sharedObjectId;
......
......@@ -1284,7 +1284,7 @@ int JBIG2Stream::lookChar() {
return EOF;
}
int JBIG2Stream::getPos() {
Goffset JBIG2Stream::getPos() {
if (pageBitmap == NULL) {
return 0;
}
......@@ -1320,7 +1320,7 @@ void JBIG2Stream::readSegments() {
Guint segNum, segFlags, segType, page, segLength;
Guint refFlags, nRefSegs;
Guint *refSegs;
int segDataPos;
Goffset segDataPos;
int c1, c2, c3;
Guint i;
......@@ -1483,7 +1483,7 @@ void JBIG2Stream::readSegments() {
if (segLength != 0xffffffff) {
int segExtraBytes = segDataPos + segLength - curStr->getPos();
Goffset segExtraBytes = segDataPos + segLength - curStr->getPos();
if (segExtraBytes > 0) {
// If we didn't read all of the bytes in the segment data,
......@@ -1501,7 +1501,7 @@ void JBIG2Stream::readSegments() {
// hopefully we're not doing this much
int trash;
for (int i = segExtraBytes; i > 0; i--) {
for (Goffset i = segExtraBytes; i > 0; i--) {
readByte(&trash);
}
......
......@@ -50,7 +50,7 @@ public:
virtual StreamKind getKind() { return strJBIG2; }
virtual void reset();
virtual void close();
virtual int getPos();
virtual Goffset getPos();
virtual int getChar();
virtual int lookChar();
virtual GooString *getPSFilter(int psLevel, const char *indent);
......
......@@ -46,7 +46,7 @@ void JPXStream::close() {
}
}
int JPXStream::getPos() {
Goffset JPXStream::getPos() {
return counter * ncomps + ccounter;
}
......
......@@ -29,7 +29,7 @@ public:
virtual StreamKind getKind() { return strJPX; }
virtual void reset();
virtual void close();
virtual int getPos();
virtual Goffset getPos();
virtual int getChar();
virtual int lookChar();
virtual GooString *getPSFilter(int psLevel, const char *indent);
......
......@@ -67,12 +67,12 @@ public:
{ return curStr.isStream() ? curStr.getStream() : (Stream *)NULL; }
// Get current position in file. This is only used for error
// messages, so it returns an int instead of a Guint.
int getPos()
{ return curStr.isStream() ? (int)curStr.streamGetPos() : -1; }
// messages.
Goffset getPos()
{ return curStr.isStream() ? curStr.streamGetPos() : -1; }
// Set position in file.
void setPos(Guint pos, int dir = 0)
void setPos(Goffset pos, int dir = 0)
{ if (curStr.isStream()) curStr.streamSetPos(pos, dir); }
// Returns true if <c> is a whitespace character.
......
......@@ -234,8 +234,8 @@ public:
int streamGetChars(int nChars, Guchar *buffer);
int streamLookChar();
char *streamGetLine(char *buf, int size);
Guint streamGetPos();
void streamSetPos(Guint pos, int dir = 0);
Goffset streamGetPos();
void streamSetPos(Goffset pos, int dir = 0);
Dict *streamGetDict();
// Output.
......@@ -355,10 +355,10 @@ inline int Object::streamLookChar()
inline char *Object::streamGetLine(char *buf, int size)
{ OBJECT_TYPE_CHECK(objStream); return stream->getLine(buf, size); }
inline Guint Object::streamGetPos()
inline Goffset Object::streamGetPos()
{ OBJECT_TYPE_CHECK(objStream); return stream->getPos(); }
inline void Object::streamSetPos(Guint pos, int dir)
inline void Object::streamSetPos(Goffset pos, int dir)
{ OBJECT_TYPE_CHECK(objStream); stream->setPos(pos, dir); }
inline Dict *Object::streamGetDict()
......
......@@ -117,7 +117,7 @@ void PDFDoc::init()
#ifndef DISABLE_OUTLINE
outline = NULL;
#endif
startXRefPos = ~(Guint)0;
startXRefPos = -1;
secHdlr = NULL;
pageCache = NULL;
}
......@@ -130,7 +130,7 @@ PDFDoc::PDFDoc()
PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword,
GooString *userPassword, void *guiDataA) {
Object obj;
int size = 0;
Goffset size = 0;
#ifdef _WIN32
int n, i;
#endif
......@@ -369,7 +369,7 @@ PDFDoc::~PDFDoc() {
GBool PDFDoc::checkFooter() {
// we look in the last 1024 chars because Adobe does the same
char *eof = new char[1025];
int pos = str->getPos();
Goffset pos = str->getPos();
str->setPos(1024, -1);
int i, ch;
for (i = 0; i < 1024; i++)
......@@ -767,7 +767,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo)
objectsCount++;
page.free();
Guint uxrefOffset = outStr->getPos();
Goffset uxrefOffset = outStr->getPos();
Ref ref;
ref.num = rootNum;
ref.gen = 0;
......@@ -906,7 +906,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
return;
}
Guint uxrefOffset = outStr->getPos();
Goffset uxrefOffset = outStr->getPos();
int numobjects = xref->getNumObjects();
const char *fileNameA = fileName ? fileName->getCString() : NULL;
Ref rootRef, uxrefStreamRef;
......@@ -991,7 +991,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr)
}
}
xref->unlock();
Guint uxrefOffset = outStr->getPos();
Goffset uxrefOffset = outStr->getPos();
writeXRefTableTrailer(uxrefOffset, uxref, gTrue /* write all entries */,
uxref->getNumObjects(), outStr, gFalse /* complete rewrite */);
delete uxref;
......@@ -1027,17 +1027,21 @@ void PDFDoc::writeRawStream (Stream* str, OutStream* outStr)
{
Object obj1;
str->getDict()->lookup("Length", &obj1);
if (!obj1.isInt()) {
if (!obj1.isInt() && !obj1.isInt64()) {
error (errSyntaxError, -1, "PDFDoc::writeRawStream, no Length in stream dict");
return;
}
const int length = obj1.getInt();
Goffset length;
if (obj1.isInt())
length = obj1.getInt();
else
length = obj1.getInt64();
obj1.free();
outStr->printf("stream\r\n");
str->unfilteredReset();
for (int i=0; i<length; i++) {
for (Goffset i = 0; i < length; i++) {
int c = str->getUnfilteredChar();
outStr->printf("%c", c);
}
......@@ -1103,7 +1107,7 @@ void PDFDoc::writeString (GooString* s, OutStream* outStr, Guchar *fileKey,
Guint PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr)
{
Guint offset = outStr->getPos();
Goffset offset = outStr->getPos();
outStr->printf("%i %i obj ", ref->num, ref->gen);
return offset;
}
......@@ -1113,7 +1117,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
{
Array *array;
Object obj1;
int tmp;
Goffset tmp;
switch (obj->getType()) {
case objBool:
......@@ -1180,7 +1184,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
for (int c=stream->getChar(); c!=EOF; c=stream->getChar()) {
tmp++;
}
obj1.initInt(tmp);
obj1.initInt64(tmp);
stream->getDict()->set("Length", &obj1);
//Remove Stream encoding
......@@ -1197,10 +1201,10 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
if (fs) {
BaseStream *bs = fs->getBaseStream();
if (bs) {
Guint streamEnd;
Goffset streamEnd;
if (xRef->getStreamEnd(bs->getStart(), &streamEnd)) {
Object val;
val.initInt(streamEnd - bs->getStart());
val.initInt64(streamEnd - bs->getStart());
stream->getDict()->set("Length", &val);
}
}
......@@ -1237,7 +1241,7 @@ void PDFDoc::writeObjectFooter (OutStream* outStr)
}
Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef,
Ref *root, XRef *xRef, const char *fileName, Guint fileSize)
Ref *root, XRef *xRef, const char *fileName, Goffset fileSize)
{
Dict *trailerDict = new Dict(xRef);
Object obj1;
......@@ -1258,7 +1262,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef
if (fileName)
message.append(fileName);
sprintf(buffer, "%i", fileSize);
sprintf(buffer, "%lli", (long long)fileSize);
message.append(buffer);
//info dict -- only use text string
......@@ -1336,7 +1340,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef
return trailerDict;
}
void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAllEntries, Guint uxrefOffset, OutStream* outStr, XRef *xRef)
void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAllEntries, Goffset uxrefOffset, OutStream* outStr, XRef *xRef)
{
uxref->writeTableToFile( outStr, writeAllEntries );
outStr->printf( "trailer\r\n");
......@@ -1346,7 +1350,7 @@ void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAl
outStr->printf( "%%%%EOF\r\n");
}
void PDFDoc::writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefStreamRef, Guint uxrefOffset, OutStream* outStr, XRef *xRef)
void PDFDoc::writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefStreamRef, Goffset uxrefOffset, OutStream* outStr, XRef *xRef)
{
GooString stmData;
......@@ -1609,14 +1613,14 @@ PDFDoc *PDFDoc::ErrorPDFDoc(int errorCode, GooString *fileNameA)
return doc;
}
Guint PDFDoc::strToUnsigned(char *s) {
Guint x, d;
long long PDFDoc::strToLongLong(char *s) {
long long x, d;
char *p;
x = 0;
for (p = s; *p && isdigit(*p & 0xff); ++p) {
d = *p - '0';
if (x > (UINT_MAX - d) / 10) {
if (x > (LLONG_MAX - d) / 10) {
break;
}
x = 10 * x + d;
......@@ -1625,9 +1629,9 @@ Guint PDFDoc::strToUnsigned(char *s) {
}
// Read the 'startxref' position.
Guint PDFDoc::getStartXRef()
Goffset PDFDoc::getStartXRef()
{
if (startXRefPos == ~(Guint)0) {
if (startXRefPos == -1) {
if (isLinearized()) {
char buf[linearizationSearchSize+1];
......@@ -1678,7 +1682,7 @@ Guint PDFDoc::getStartXRef()
startXRefPos = 0;
} else {
for (p = &buf[i+9]; isspace(*p); ++p) ;
startXRefPos = strToUnsigned(p);
startXRefPos = strToLongLong(p);
}
}
......@@ -1687,7 +1691,7 @@ Guint PDFDoc::getStartXRef()
return startXRefPos;
}
Guint PDFDoc::getMainXRefEntriesOffset()
Goffset PDFDoc::getMainXRefEntriesOffset()
{
Guint mainXRefEntriesOffset = 0;
......
......@@ -252,11 +252,11 @@ public:
// Ownership goes to the caller
static Dict *createTrailerDict (int uxrefSize, GBool incrUpdate, Guint startxRef,
Ref *root, XRef *xRef, const char *fileName, Guint fileSize);
Ref *root, XRef *xRef, const char *fileName, Goffset fileSize);
static void writeXRefTableTrailer (Dict *trailerDict, XRef *uxref, GBool writeAllEntries,
Guint uxrefOffset, OutStream* outStr, XRef *xRef);
Goffset uxrefOffset, OutStream* outStr, XRef *xRef);
static void writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefStreamRef,
Guint uxrefOffset, OutStream* outStr, XRef *xRef);
Goffset uxrefOffset, OutStream* outStr, XRef *xRef);
private:
// insert referenced objects in XRef
......@@ -296,11 +296,11 @@ private:
void checkHeader();
GBool checkEncryption(GooString *ownerPassword, GooString *userPassword);
// Get the offset of the start xref table.
Guint getStartXRef();
Goffset getStartXRef();
// Get the offset of the entries in the main XRef table of a
// linearized document (0 for non linearized documents).
Guint getMainXRefEntriesOffset();
Guint strToUnsigned(char *s);
Goffset getMainXRefEntriesOffset();
long long strToLongLong(char *s);
GooString *fileName;
#ifdef _WIN32
......@@ -327,7 +327,7 @@ private:
//then the POSIX errno will be here.
int fopenErrno;
Guint startXRefPos; // offset of last xref table
Goffset startXRefPos; // offset of last xref table
#if MULTITHREADED
GooMutex mutex;
#endif
......
......@@ -194,7 +194,8 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
Object obj;
BaseStream *baseStr;
Stream *str;
Guint pos, endPos, length;
Goffset length;
Goffset pos, endPos;
// get stream start position
lexer->skipToNextLine();
......@@ -206,7 +207,10 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
// get length
dict->dictLookup("Length", &obj, recursion);
if (obj.isInt()) {
length = (Guint)obj.getInt();
length = obj.getInt();
obj.free();
} else if (obj.isInt64()) {
length = obj.getInt64();
obj.free();
} else {
error(errSyntaxError, getPos(), "Bad 'Length' attribute in stream");
......@@ -250,7 +254,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
}
length = lexer->getPos() - pos;
if (buf1.isCmd("endstream")) {
obj.initInt(length);
obj.initInt64(length);
dict->dictSet("Length", &obj);
obj.free();
}
......
......@@ -58,7 +58,7 @@ public:
Stream *getStream() { return lexer->getStream(); }
// Get current position in file.
int getPos() { return lexer->getPos(); }
Goffset getPos() { return lexer->getPos(); }
private:
......
......@@ -366,7 +366,7 @@ OutStream::~OutStream ()
//------------------------------------------------------------------------
// FileOutStream
//------------------------------------------------------------------------
FileOutStream::FileOutStream (FILE* fa, Guint startA)
FileOutStream::FileOutStream (FILE* fa, Goffset startA)
{
f = fa;
start = startA;
......@@ -382,7 +382,7 @@ void FileOutStream::close ()
}
int FileOutStream::getPos ()
Goffset FileOutStream::getPos ()
{
return ftell(f);
}
......@@ -405,7 +405,7 @@ void FileOutStream::printf(const char *format, ...)
// BaseStream
//------------------------------------------------------------------------
BaseStream::BaseStream(Object *dictA, Guint lengthA) {
BaseStream::BaseStream(Object *dictA, Goffset lengthA) {
dict = *dictA;
length = lengthA;
}
......@@ -429,7 +429,7 @@ void FilterStream::close() {
str->close();
}
void FilterStream::setPos(Guint pos, int dir) {
void FilterStream::setPos(Goffset pos, int dir) {
error(errInternal, -1, "Internal: called setPos() on FilterStream");
}
......@@ -771,8 +771,8 @@ UniqueFileStream::~UniqueFileStream() {
// FileStream
//------------------------------------------------------------------------
FileStream::FileStream(FILE *fA, char *fileNameA, Guint startA, GBool limitedA,
Guint lengthA, Object *dictA):
FileStream::FileStream(FILE *fA, char *fileNameA, Goffset startA, GBool limitedA,
Goffset lengthA, Object *dictA):
BaseStream(dictA, lengthA) {
f = fA;
fileName = fileNameA;
......@@ -793,20 +793,20 @@ BaseStream *FileStream::copy() {
return new UniqueFileStream(f, fileName, start, limited, length, &dict);
}
Stream *FileStream::makeSubStream(Guint startA, GBool limitedA,
Guint lengthA, Object *dictA) {
Stream *FileStream::makeSubStream(Goffset startA, GBool limitedA,
Goffset lengthA, Object *dictA) {
return new FileStream(f, fileName, startA, limitedA, lengthA, dictA);
}
void FileStream::reset() {
#if HAVE_FSEEKO
savePos = (Guint)ftello(f);
savePos = ftello(f);
fseeko(f, start, SEEK_SET);
#elif HAVE_FSEEK64
savePos = (Guint)ftell64(f);
savePos = ftell64(f);
fseek64(f, start, SEEK_SET);
#else
savePos = (Guint)ftell(f);
savePos = ftell(f);
fseek(f, start, SEEK_SET);
#endif
saved = gTrue;
......@@ -848,8 +848,8 @@ GBool FileStream::fillBuf() {
return gTrue;
}
void FileStream::setPos(Guint pos, int dir) {
Guint size;
void FileStream::setPos(Goffset pos, int dir) {
Goffset size;
if (dir >= 0) {
#if HAVE_FSEEKO
......@@ -863,31 +863,31 @@ void FileStream::setPos(Guint pos, int dir) {
} else {
#if HAVE_FSEEKO
fseeko(f, 0, SEEK_END);
size = (Guint)ftello(f);
size = ftello(f);
#elif HAVE_FSEEK64
fseek64(f, 0, SEEK_END);
size = (Guint)ftell64(f);
size = ftell64(f);
#else
fseek(f, 0, SEEK_END);
size = (Guint)ftell(f);
size = ftell(f);
#endif
if (pos > size)
pos = (Guint)size;
pos = size;
#if HAVE_FSEEKO
fseeko(f, -(int)pos, SEEK_END);
bufPos = (Guint)ftello(f);
fseeko(f, -pos, SEEK_END);
bufPos = ftello(f);
#elif HAVE_FSEEK64
fseek64(f, -(int)pos, SEEK_END);
bufPos = (Guint)ftell64(f);