diff options
Diffstat (limited to 'libqpdf/FileInputSource.cc')
-rw-r--r-- | libqpdf/FileInputSource.cc | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc index a1b1ced5..4e4a34bf 100644 --- a/libqpdf/FileInputSource.cc +++ b/libqpdf/FileInputSource.cc @@ -120,15 +120,23 @@ FileInputSource::rewind() size_t FileInputSource::read(char* buffer, size_t length) { - this->last_offset = QUtil::tell(this->file); + this->last_offset = this->tell(); size_t len = fread(buffer, 1, length, this->file); - if ((len == 0) && ferror(this->file)) + if (len == 0) { - throw QPDFExc(qpdf_e_system, - this->filename, "", - this->last_offset, - std::string("read ") + - QUtil::int_to_string(length) + " bytes"); + if (ferror(this->file)) + { + throw QPDFExc(qpdf_e_system, + this->filename, "", + this->last_offset, + std::string("read ") + + QUtil::int_to_string(length) + " bytes"); + } + else if (length > 0) + { + this->seek(0, SEEK_END); + this->last_offset = this->tell(); + } } return len; } |