summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/qpdf/QPDF.hh10
-rw-r--r--libqpdf/QPDF.cc14
-rw-r--r--qpdf/test_driver.cc2
3 files changed, 15 insertions, 11 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index 0c6bf44d..59d26133 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -55,10 +55,12 @@ class QPDF
// Parse a PDF from a stdio FILE*. The FILE must be open in
// binary mode and must be seekable. It may be open read only.
// This works exactly like processFile except that the PDF file is
- // read from an already opened FILE*. The caller is responsible
- // for closing the file.
+ // read from an already opened FILE*. If close_file is true, the
+ // file will be closed at the end. Otherwise, the caller is
+ // responsible for closing the file.
QPDF_DLL
- void processFile(FILE* file, char const* password = 0);
+ void processFile(char const* description, FILE* file,
+ bool close_file, char const* password = 0);
// Parse a PDF file loaded into a memory buffer. This works
// exactly like processFile except that the PDF file is in memory
@@ -449,7 +451,7 @@ class QPDF
public:
FileInputSource();
void setFilename(char const* filename);
- void setFile(FILE* filep);
+ void setFile(char const* description, FILE* filep, bool close_file);
virtual ~FileInputSource();
virtual std::string const& getName() const;
virtual qpdf_offset_t tell();
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 5f1ab48c..3ea2f1ff 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -114,12 +114,13 @@ QPDF::FileInputSource::setFilename(char const* filename)
}
void
-QPDF::FileInputSource::setFile(FILE* f)
+QPDF::FileInputSource::setFile(
+ char const* description, FILE* filep, bool close_file)
{
destroy();
- this->filename = "stdio FILE";
- this->close_file = false;
- this->file = f;
+ this->filename = description;
+ this->close_file = close_file;
+ this->file = filep;
this->seek(0, SEEK_SET);
}
@@ -347,11 +348,12 @@ QPDF::processFile(char const* filename, char const* password)
}
void
-QPDF::processFile(FILE* filep, char const* password)
+QPDF::processFile(char const* description, FILE* filep,
+ bool close_file, char const* password)
{
FileInputSource* fi = new FileInputSource();
this->file = fi;
- fi->setFile(filep);
+ fi->setFile(description, filep, close_file);
parse(password);
}
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index e7b78c4a..a3d2570c 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -104,7 +104,7 @@ void runtest(int n, char const* filename)
QTC::TC("qpdf", "exercise processFile(FILE*)");
filep = QUtil::fopen_wrapper(std::string("open ") + filename,
fopen(filename, "rb"));
- pdf.processFile(filep);
+ pdf.processFile(filename, filep, false);
}
}
else