diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-07-06 03:22:27 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-07-06 03:24:04 +0200 |
commit | 8705e2e8fc1a9721b2438c09ba7e92ec673af19d (patch) | |
tree | bba745e53ae9aa63a883bc8b3d4fbef797f0cb9f /libqpdf | |
parent | 3b5d72b9462988bbbf9422aa82954414368533d9 (diff) | |
download | qpdf-8705e2e8fc1a9721b2438c09ba7e92ec673af19d.tar.zst |
Add QPDFWriter method to output to FILE*
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFWriter.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 564133e3..a7c78b19 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -34,6 +34,14 @@ QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) : setOutputFilename(filename); } +QPDFWriter::QPDFWriter(QPDF& pdf, char const* description, + FILE *file, bool close_file) : + pdf(pdf) +{ + init(); + setOutputFile(description, file, close_file); +} + void QPDFWriter::init() { @@ -79,21 +87,31 @@ QPDFWriter::~QPDFWriter() void QPDFWriter::setOutputFilename(char const* filename) { - this->filename = filename; + char const* description = filename; + FILE* f = 0; if (filename == 0) { - this->filename = "standard output"; + description = "standard output"; QTC::TC("qpdf", "QPDFWriter write to stdout"); - file = stdout; + f = stdout; QUtil::binary_stdout(); } else { QTC::TC("qpdf", "QPDFWriter write to file"); - file = QUtil::fopen_wrapper(std::string("open ") + filename, - fopen(filename, "wb+")); + f = QUtil::fopen_wrapper(std::string("open ") + filename, + fopen(filename, "wb+")); close_file = true; } + setOutputFile(description, f, close_file); +} + +void +QPDFWriter::setOutputFile(char const* description, FILE* file, bool close_file) +{ + this->filename = description; + this->file = file; + this->close_file = close_file; Pipeline* p = new Pl_StdioFile("qpdf output", file); to_delete.push_back(p); initializePipelineStack(p); |