diff options
author | m-holger <m-holger@kubitscheck.org> | 2022-08-25 15:23:53 +0200 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2022-08-27 13:13:39 +0200 |
commit | d6a447b654592cc1d1118a54bdedcc142ac8d434 (patch) | |
tree | ca2175f8ae341e73135469c74fedcb5cb33700c1 /libqpdf | |
parent | 69a5fb70472a2112d2bbb938ee3718250d2364cf (diff) | |
download | qpdf-d6a447b654592cc1d1118a54bdedcc142ac8d434.tar.zst |
Remove ClosedFileInputSource::Members
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/ClosedFileInputSource.cc | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc index ec977c69..06ebb156 100644 --- a/libqpdf/ClosedFileInputSource.cc +++ b/libqpdf/ClosedFileInputSource.cc @@ -2,18 +2,13 @@ #include <qpdf/FileInputSource.hh> -ClosedFileInputSource::Members::Members(char const* filename) : +ClosedFileInputSource::ClosedFileInputSource(char const* filename) : filename(filename), offset(0), stay_open(false) { } -ClosedFileInputSource::ClosedFileInputSource(char const* filename) : - m(new Members(filename)) -{ -} - ClosedFileInputSource::~ClosedFileInputSource() { // Must be explicit and not inline -- see QPDF_DLL_CLASS in @@ -23,30 +18,29 @@ ClosedFileInputSource::~ClosedFileInputSource() void ClosedFileInputSource::before() { - if (nullptr == this->m->fis) { - this->m->fis = - std::make_shared<FileInputSource>(this->m->filename.c_str()); - this->m->fis->seek(this->m->offset, SEEK_SET); - this->m->fis->setLastOffset(this->last_offset); + if (nullptr == this->fis) { + this->fis = std::make_shared<FileInputSource>(this->filename.c_str()); + this->fis->seek(this->offset, SEEK_SET); + this->fis->setLastOffset(this->last_offset); } } void ClosedFileInputSource::after() { - this->last_offset = this->m->fis->getLastOffset(); - this->m->offset = this->m->fis->tell(); - if (this->m->stay_open) { + this->last_offset = this->fis->getLastOffset(); + this->offset = this->fis->tell(); + if (this->stay_open) { return; } - this->m->fis = nullptr; + this->fis = nullptr; } qpdf_offset_t ClosedFileInputSource::findAndSkipNextEOL() { before(); - qpdf_offset_t r = this->m->fis->findAndSkipNextEOL(); + qpdf_offset_t r = this->fis->findAndSkipNextEOL(); after(); return r; } @@ -54,14 +48,14 @@ ClosedFileInputSource::findAndSkipNextEOL() std::string const& ClosedFileInputSource::getName() const { - return this->m->filename; + return this->filename; } qpdf_offset_t ClosedFileInputSource::tell() { before(); - qpdf_offset_t r = this->m->fis->tell(); + qpdf_offset_t r = this->fis->tell(); after(); return r; } @@ -70,16 +64,16 @@ void ClosedFileInputSource::seek(qpdf_offset_t offset, int whence) { before(); - this->m->fis->seek(offset, whence); + this->fis->seek(offset, whence); after(); } void ClosedFileInputSource::rewind() { - this->m->offset = 0; - if (this->m->fis.get()) { - this->m->fis->rewind(); + this->offset = 0; + if (this->fis.get()) { + this->fis->rewind(); } } @@ -87,7 +81,7 @@ size_t ClosedFileInputSource::read(char* buffer, size_t length) { before(); - size_t r = this->m->fis->read(buffer, length); + size_t r = this->fis->read(buffer, length); after(); return r; } @@ -96,7 +90,7 @@ void ClosedFileInputSource::unreadCh(char ch) { before(); - this->m->fis->unreadCh(ch); + this->fis->unreadCh(ch); // Don't call after -- the file has to stay open after this // operation. } @@ -104,8 +98,8 @@ ClosedFileInputSource::unreadCh(char ch) void ClosedFileInputSource::stayOpen(bool val) { - this->m->stay_open = val; - if ((!val) && this->m->fis.get()) { + this->stay_open = val; + if ((!val) && this->fis.get()) { after(); } } |