Lines 39-51
Link Here
|
39 |
|
39 |
|
40 |
CPL_CVSID("$Id: pdfio.cpp 27044 2014-03-16 23:41:27Z rouault $"); |
40 |
CPL_CVSID("$Id: pdfio.cpp 27044 2014-03-16 23:41:27Z rouault $"); |
41 |
|
41 |
|
|
|
42 |
|
43 |
#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS |
44 |
/* Poppler 0.31.0 is the first one that needs to know the file size */ |
45 |
static vsi_l_offset VSIPDFFileStreamGetSize(VSILFILE* f) |
46 |
{ |
47 |
VSIFSeekL(f, 0, SEEK_END); |
48 |
vsi_l_offset nSize = VSIFTellL(f); |
49 |
VSIFSeekL(f, 0, SEEK_SET); |
50 |
return nSize; |
51 |
} |
52 |
#endif |
53 |
|
42 |
/************************************************************************/ |
54 |
/************************************************************************/ |
43 |
/* VSIPDFFileStream() */ |
55 |
/* VSIPDFFileStream() */ |
44 |
/************************************************************************/ |
56 |
/************************************************************************/ |
45 |
|
57 |
|
46 |
VSIPDFFileStream::VSIPDFFileStream(VSILFILE* f, const char* pszFilename, Object *dictA): |
58 |
VSIPDFFileStream::VSIPDFFileStream(VSILFILE* f, const char* pszFilename, Object *dictA): |
47 |
#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS |
59 |
#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS |
48 |
BaseStream(dictA, 0) |
60 |
BaseStream(dictA, (setPos_offset_type)VSIPDFFileStreamGetSize(f)) |
49 |
#else |
61 |
#else |
50 |
BaseStream(dictA) |
62 |
BaseStream(dictA) |
51 |
#endif |
63 |
#endif |
Lines 195-201
int VSIPDFFileStream::FillBuffer()
Link Here
|
195 |
/* getChar() */ |
207 |
/* getChar() */ |
196 |
/************************************************************************/ |
208 |
/************************************************************************/ |
197 |
|
209 |
|
198 |
/* The unoptimized version performs a bit well since we must go through */ |
210 |
/* The unoptimized version performs a bit less since we must go through */ |
199 |
/* the whole virtual I/O chain for each character reading. We save a few */ |
211 |
/* the whole virtual I/O chain for each character reading. We save a few */ |
200 |
/* percent with this extra internal caching */ |
212 |
/* percent with this extra internal caching */ |
201 |
|
213 |
|
Lines 326-329
void VSIPDFFileStream::moveStart(moveSta
Link Here
|
326 |
nPosInBuffer = nBufferLength = -1; |
338 |
nPosInBuffer = nBufferLength = -1; |
327 |
} |
339 |
} |
328 |
|
340 |
|
|
|
341 |
/************************************************************************/ |
342 |
/* hasGetChars() */ |
343 |
/************************************************************************/ |
344 |
|
345 |
GBool VSIPDFFileStream::hasGetChars() |
346 |
{ |
347 |
return true; |
348 |
} |
349 |
|
350 |
/************************************************************************/ |
351 |
/* getChars() */ |
352 |
/************************************************************************/ |
353 |
|
354 |
int VSIPDFFileStream::getChars(int nChars, Guchar *buffer) |
355 |
{ |
356 |
int nRead = 0; |
357 |
while (nRead < nChars) |
358 |
{ |
359 |
int nToRead = nChars - nRead; |
360 |
if (nPosInBuffer == nBufferLength) |
361 |
{ |
362 |
if (!bLimited && nToRead > BUFFER_SIZE) |
363 |
{ |
364 |
int nJustRead = (int) VSIFReadL(buffer + nRead, 1, nToRead, f); |
365 |
nPosInBuffer = nBufferLength = -1; |
366 |
nCurrentPos += nJustRead; |
367 |
nRead += nJustRead; |
368 |
break; |
369 |
} |
370 |
else if (!FillBuffer() || nPosInBuffer >= nBufferLength) |
371 |
break; |
372 |
} |
373 |
if( nToRead > nBufferLength - nPosInBuffer ) |
374 |
nToRead = nBufferLength - nPosInBuffer; |
375 |
|
376 |
memcpy( buffer + nRead, abyBuffer + nPosInBuffer, nToRead ); |
377 |
nPosInBuffer += nToRead; |
378 |
nCurrentPos += nToRead; |
379 |
nRead += nToRead; |
380 |
} |
381 |
return nRead; |
382 |
} |
383 |
|
329 |
#endif |
384 |
#endif |