mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Add new FileInputSource constructors
This commit is contained in:
parent
e259635986
commit
e5f3910c3e
@ -1,5 +1,8 @@
|
||||
2022-05-04 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* FileInputSource has new constructors that eliminate the need to
|
||||
call setFilename or setFile in most cases.
|
||||
|
||||
* Enhance JSON by adding a write method that takes a Pipeline* and
|
||||
depth, and add several helper methods to make it easier to write
|
||||
large amounts of JSON incrementally without having to have the
|
||||
|
@ -30,6 +30,10 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource
|
||||
QPDF_DLL
|
||||
FileInputSource();
|
||||
QPDF_DLL
|
||||
FileInputSource(char const* filename);
|
||||
QPDF_DLL
|
||||
FileInputSource(char const* description, FILE* filep, bool close_file);
|
||||
QPDF_DLL
|
||||
void setFilename(char const* filename);
|
||||
QPDF_DLL
|
||||
void setFile(char const* description, FILE* filep, bool close_file);
|
||||
|
@ -24,8 +24,8 @@ void
|
||||
ClosedFileInputSource::before()
|
||||
{
|
||||
if (0 == this->m->fis.get()) {
|
||||
this->m->fis = std::make_shared<FileInputSource>();
|
||||
this->m->fis->setFilename(this->m->filename.c_str());
|
||||
this->m->fis =
|
||||
std::make_shared<FileInputSource>(this->m->filename.c_str());
|
||||
this->m->fis->seek(this->m->offset, SEEK_SET);
|
||||
this->m->fis->setLastOffset(this->last_offset);
|
||||
}
|
||||
|
@ -23,6 +23,19 @@ FileInputSource::FileInputSource() :
|
||||
{
|
||||
}
|
||||
|
||||
FileInputSource::FileInputSource(char const* filename) :
|
||||
m(new Members(false))
|
||||
{
|
||||
setFilename(filename);
|
||||
}
|
||||
|
||||
FileInputSource::FileInputSource(
|
||||
char const* description, FILE* filep, bool close_file) :
|
||||
m(new Members(false))
|
||||
{
|
||||
setFile(description, filep, close_file);
|
||||
}
|
||||
|
||||
void
|
||||
FileInputSource::setFilename(char const* filename)
|
||||
{
|
||||
|
@ -270,8 +270,7 @@ QPDF::~QPDF()
|
||||
void
|
||||
QPDF::processFile(char const* filename, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFilename(filename);
|
||||
FileInputSource* fi = new FileInputSource(filename);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
@ -279,8 +278,7 @@ void
|
||||
QPDF::processFile(
|
||||
char const* description, FILE* filep, bool close_file, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFile(description, filep, close_file);
|
||||
FileInputSource* fi = new FileInputSource(description, filep, close_file);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
|
@ -2445,9 +2445,9 @@ QPDFJob::handlePageSpecs(
|
||||
cis->stayOpen(true);
|
||||
} else {
|
||||
QTC::TC("qpdf", "QPDFJob keep files open y");
|
||||
FileInputSource* fis = new FileInputSource();
|
||||
FileInputSource* fis =
|
||||
new FileInputSource(page_spec.filename.c_str());
|
||||
is = std::shared_ptr<InputSource>(fis);
|
||||
fis->setFilename(page_spec.filename.c_str());
|
||||
}
|
||||
std::shared_ptr<QPDF> qpdf_ph =
|
||||
processInputSource(is, password, true);
|
||||
|
@ -73,8 +73,7 @@ main()
|
||||
do_tests(&cf2);
|
||||
cf2.stayOpen(false);
|
||||
std::cout << "testing with FileInputSource\n";
|
||||
FileInputSource f;
|
||||
f.setFilename("input");
|
||||
FileInputSource f("input");
|
||||
do_tests(&f);
|
||||
std::cout << "all assertions passed" << std::endl;
|
||||
return 0;
|
||||
|
@ -191,8 +191,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
|
||||
std::shared_ptr<InputSource> is;
|
||||
|
||||
// Tokenize file, skipping streams
|
||||
FileInputSource* fis = new FileInputSource();
|
||||
fis->setFilename(filename);
|
||||
FileInputSource* fis = new FileInputSource(filename);
|
||||
is = std::shared_ptr<InputSource>(fis);
|
||||
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user