From c4e56fa5f40188ddf4f75d316e57143c10ed51fa Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 23 Jan 2022 13:04:08 -0500 Subject: [PATCH] QPDFJob: make createsOutput callable before run() --- include/qpdf/QPDFJob.hh | 8 ++++---- libqpdf/QPDFJob.cc | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index d8c698a5..921742db 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -85,6 +85,10 @@ class QPDFJob QPDF_DLL void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream); + // Returns true if output is created by the specified job. + QPDF_DLL + bool createsOutput() const; + // QXXXQ set options -- implemented in QPDFJob_options.cc // QXXXQ these will not be in the final interface @@ -108,9 +112,6 @@ class QPDFJob QPDF_DLL bool hasWarnings(); - QPDF_DLL - bool createsOutput(); // QXXXQ need better name - // Return value is bitwise OR of values from qpdf_encryption_status_e QPDF_DLL unsigned long getEncryptionStatus(); @@ -398,7 +399,6 @@ class QPDFJob std::string message_prefix; bool warnings; - bool creates_output; std::ostream* cout; std::ostream* cerr; unsigned long encryption_status; diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 0a394745..0c772efb 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -322,7 +322,6 @@ ProgressReporter::reportProgress(int percentage) QPDFJob::Members::Members() : message_prefix("qpdf"), warnings(false), - creates_output(false), cout(&std::cout), cerr(&std::cerr), encryption_status(0) @@ -500,8 +499,7 @@ QPDFJob::run() handleUnderOverlay(pdf); handleTransformations(pdf); - this->m->creates_output = ((o.outfilename != nullptr) || o.replace_input); - if (! this->m->creates_output) + if (! createsOutput()) { doInspection(pdf); } @@ -526,9 +524,10 @@ QPDFJob::hasWarnings() } bool -QPDFJob::createsOutput() +QPDFJob::createsOutput() const { - return this->m->creates_output; + QPDFJob const& o = *this; // QXXXQ + return ((o.outfilename != nullptr) || o.replace_input); } bool