Commit babd12c9b2b824416d2e5992d961396090e2bfea

Authored by Jay Berkenbilt
1 parent 41b5c464

Add methods QPDF::anyWarnings and QPDF::closeInputSource

ChangeLog
1 1 2019-08-31 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Add QPDF::anyWarnings() method to find out whether there have
  4 + been any warnings without resetting the list.
  5 +
  6 + * Add QPDF::closeInputSource() method to release the input source
  7 + so the input file can be deleted or renamed.
  8 +
3 9 * Add methods rename_file and remove_file to QUtil.
4 10  
5 11 2019-08-24 Jay Berkenbilt <ejb@ql.org>
... ...
include/qpdf/QPDF.hh
... ... @@ -101,6 +101,14 @@ class QPDF
101 101 void processInputSource(PointerHolder<InputSource>,
102 102 char const* password = 0);
103 103  
  104 + // Close or otherwise release the input source. Once this has been
  105 + // called, no other methods of qpdf can be called safely except
  106 + // for getWarnings and anyWarnings(). After this has been called,
  107 + // it is safe to perform operations on the input file such as
  108 + // deleting or renaming it.
  109 + QPDF_DLL
  110 + void closeInputSource();
  111 +
104 112 // For certain forensic or investigatory purposes, it may
105 113 // sometimes be useful to specify the encryption key directly,
106 114 // even though regular PDF applications do not provide a way to do
... ... @@ -206,6 +214,11 @@ class QPDF
206 214 QPDF_DLL
207 215 std::vector<QPDFExc> getWarnings();
208 216  
  217 + // Indicate whether any warnings have been issued so far. Does not
  218 + // clear the list of warnings.
  219 + QPDF_DLL
  220 + bool anyWarnings() const;
  221 +
209 222 // Return an application-scoped unique ID for this QPDF object.
210 223 // This is not a globally unique ID. It is constructing using a
211 224 // timestamp and a random number and is intended to be unique
... ...
libqpdf/QPDF.cc
... ... @@ -240,6 +240,12 @@ QPDF::processInputSource(PointerHolder&lt;InputSource&gt; source,
240 240 }
241 241  
242 242 void
  243 +QPDF::closeInputSource()
  244 +{
  245 + this->m->file = 0;
  246 +}
  247 +
  248 +void
243 249 QPDF::setPasswordIsHexKey(bool val)
244 250 {
245 251 this->m->provided_password_is_hex_key = val;
... ... @@ -291,6 +297,12 @@ QPDF::getWarnings()
291 297 }
292 298  
293 299 bool
  300 +QPDF::anyWarnings() const
  301 +{
  302 + return ! this->m->warnings.empty();
  303 +}
  304 +
  305 +bool
294 306 QPDF::findHeader()
295 307 {
296 308 qpdf_offset_t global_offset = this->m->file->tell();
... ...
manual/qpdf-manual.xml
... ... @@ -4429,7 +4429,7 @@ print &quot;\n&quot;;
4429 4429 </listitem>
4430 4430 <listitem>
4431 4431 <para>
4432   - the
  4432 + The
4433 4433 <option>--compression-level=<replaceable>level</replaceable></option>
4434 4434 sets the zlib compression level used for any streams
4435 4435 compressed by <literal>/FlateDecode</literal>. Most
... ... @@ -4459,6 +4459,20 @@ print &quot;\n&quot;;
4459 4459 </listitem>
4460 4460 <listitem>
4461 4461 <para>
  4462 + Method <function>QPDF::anyWarnings</function> tells whether
  4463 + there have been any warnings without clearing the list of
  4464 + warnings.
  4465 + </para>
  4466 + </listitem>
  4467 + <listitem>
  4468 + <para>
  4469 + Method <function>QPDF::closeInputSource</function> closes or
  4470 + otherwise releases the input source. This enables the input
  4471 + file to be deleted or renamed.
  4472 + </para>
  4473 + </listitem>
  4474 + <listitem>
  4475 + <para>
4462 4476 New methods have been added to <classname>QUtil</classname>
4463 4477 for converting back and forth between strings and unsigned
4464 4478 integers: <function>uint_to_string</function>,
... ...