aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/FileInputSource.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-25 15:05:36 +0200
committerm-holger <m-holger@kubitscheck.org>2022-08-25 16:04:41 +0200
commita318b203bea956dbe17c30f87c0a8a5293f027f2 (patch)
treeb4d481dd1d58d02eedca5dfae692a41006438f55 /libqpdf/FileInputSource.cc
parentdc5c8b82eb79d0ae5b92600a52162b9c0e352d6c (diff)
downloadqpdf-a318b203bea956dbe17c30f87c0a8a5293f027f2.tar.zst
Refactor FileInputSource::seek and FileInputSource::unreadCh
Avoid building error message each call "just in case".
Diffstat (limited to 'libqpdf/FileInputSource.cc')
-rw-r--r--libqpdf/FileInputSource.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc
index 1a0c2653..2c610801 100644
--- a/libqpdf/FileInputSource.cc
+++ b/libqpdf/FileInputSource.cc
@@ -102,11 +102,12 @@ FileInputSource::tell()
void
FileInputSource::seek(qpdf_offset_t offset, int whence)
{
- QUtil::os_wrapper(
- (std::string("seek to ") + this->filename + ", offset " +
- QUtil::int_to_string(offset) + " (" + QUtil::int_to_string(whence) +
- ")"),
- QUtil::seek(this->file, offset, whence));
+ if (QUtil::seek(this->file, offset, whence) == -1) {
+ QUtil::throw_system_error(
+ std::string("seek to ") + this->filename + ", offset " +
+ QUtil::int_to_string(offset) + " (" + QUtil::int_to_string(whence) +
+ ")");
+ }
}
void
@@ -140,7 +141,7 @@ FileInputSource::read(char* buffer, size_t length)
void
FileInputSource::unreadCh(char ch)
{
- QUtil::os_wrapper(
- this->filename + ": unread character",
- ungetc(static_cast<unsigned char>(ch), this->file));
+ if (ungetc(static_cast<unsigned char>(ch), this->file) == -1) {
+ QUtil::throw_system_error(this->filename + ": unread character");
+ }
}