From 99593e0eef6204e0fcf0ddcae937c81cac8a1745 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 22 Jun 2018 12:17:36 -0400 Subject: [PATCH] Use ClosedFileInputSource when merging files (fixes #154) --- ChangeLog | 4 ++++ qpdf/qpdf.cc | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66966f7b..2463c250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2018-06-22 Jay Berkenbilt + * Don't leave files open when merging. This makes it possible + merge more files at once than the operating system's open file + limit. Fixes #154. + * Add ClosedFileInputSource class, and input source that keeps its input file closed when not reading it. At the expense of some performance, this allows you to operate on many files without diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 49271c68..783548ef 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -2083,8 +2084,9 @@ static void handle_page_specs(QPDF& pdf, Options& o, QTC::TC("qpdf", "qpdf pages encryption password"); password = o.encryption_file_password; } - qpdf->processFile( - page_spec.filename.c_str(), password); + qpdf->processInputSource( + new ClosedFileInputSource( + page_spec.filename.c_str()), password); page_spec_qpdfs[page_spec.filename] = qpdf; }