Commit 99593e0eef6204e0fcf0ddcae937c81cac8a1745

Authored by Jay Berkenbilt
1 parent 4ccc8b1a

Use ClosedFileInputSource when merging files (fixes #154)

Showing 2 changed files with 8 additions and 2 deletions
ChangeLog
1 1 2018-06-22 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Don't leave files open when merging. This makes it possible
  4 + merge more files at once than the operating system's open file
  5 + limit. Fixes #154.
  6 +
3 7 * Add ClosedFileInputSource class, and input source that keeps its
4 8 input file closed when not reading it. At the expense of some
5 9 performance, this allows you to operate on many files without
... ...
qpdf/qpdf.cc
... ... @@ -7,6 +7,7 @@
7 7  
8 8 #include <qpdf/QUtil.hh>
9 9 #include <qpdf/QTC.hh>
  10 +#include <qpdf/ClosedFileInputSource.hh>
10 11 #include <qpdf/Pl_StdioFile.hh>
11 12 #include <qpdf/Pl_Discard.hh>
12 13 #include <qpdf/PointerHolder.hh>
... ... @@ -2083,8 +2084,9 @@ static void handle_page_specs(QPDF&amp; pdf, Options&amp; o,
2083 2084 QTC::TC("qpdf", "qpdf pages encryption password");
2084 2085 password = o.encryption_file_password;
2085 2086 }
2086   - qpdf->processFile(
2087   - page_spec.filename.c_str(), password);
  2087 + qpdf->processInputSource(
  2088 + new ClosedFileInputSource(
  2089 + page_spec.filename.c_str()), password);
2088 2090 page_spec_qpdfs[page_spec.filename] = qpdf;
2089 2091 }
2090 2092  
... ...