From e5f3910c3ee1f6b779455fb1516ab3c985383d8e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 4 May 2022 12:02:39 -0400 Subject: Add new FileInputSource constructors --- libqpdf/ClosedFileInputSource.cc | 4 ++-- libqpdf/FileInputSource.cc | 13 +++++++++++++ libqpdf/QPDF.cc | 6 ++---- libqpdf/QPDFJob.cc | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc index 7c4e5dbe..7d49bf70 100644 --- a/libqpdf/ClosedFileInputSource.cc +++ b/libqpdf/ClosedFileInputSource.cc @@ -24,8 +24,8 @@ void ClosedFileInputSource::before() { if (0 == this->m->fis.get()) { - this->m->fis = std::make_shared(); - this->m->fis->setFilename(this->m->filename.c_str()); + this->m->fis = + std::make_shared(this->m->filename.c_str()); this->m->fis->seek(this->m->offset, SEEK_SET); this->m->fis->setLastOffset(this->last_offset); } diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc index 9b467821..08b35056 100644 --- a/libqpdf/FileInputSource.cc +++ b/libqpdf/FileInputSource.cc @@ -23,6 +23,19 @@ FileInputSource::FileInputSource() : { } +FileInputSource::FileInputSource(char const* filename) : + m(new Members(false)) +{ + setFilename(filename); +} + +FileInputSource::FileInputSource( + char const* description, FILE* filep, bool close_file) : + m(new Members(false)) +{ + setFile(description, filep, close_file); +} + void FileInputSource::setFilename(char const* filename) { diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index aa99942c..8b8dd59e 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -270,8 +270,7 @@ QPDF::~QPDF() void QPDF::processFile(char const* filename, char const* password) { - FileInputSource* fi = new FileInputSource(); - fi->setFilename(filename); + FileInputSource* fi = new FileInputSource(filename); processInputSource(std::shared_ptr(fi), password); } @@ -279,8 +278,7 @@ void QPDF::processFile( char const* description, FILE* filep, bool close_file, char const* password) { - FileInputSource* fi = new FileInputSource(); - fi->setFile(description, filep, close_file); + FileInputSource* fi = new FileInputSource(description, filep, close_file); processInputSource(std::shared_ptr(fi), password); } diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index ca56b8d5..63312f27 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -2445,9 +2445,9 @@ QPDFJob::handlePageSpecs( cis->stayOpen(true); } else { QTC::TC("qpdf", "QPDFJob keep files open y"); - FileInputSource* fis = new FileInputSource(); + FileInputSource* fis = + new FileInputSource(page_spec.filename.c_str()); is = std::shared_ptr(fis); - fis->setFilename(page_spec.filename.c_str()); } std::shared_ptr qpdf_ph = processInputSource(is, password, true); -- cgit v1.2.3-70-g09d2