aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/ClosedFileInputSource.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/ClosedFileInputSource.cc')
-rw-r--r--libqpdf/ClosedFileInputSource.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc
index ea79a840..e9c9b3bd 100644
--- a/libqpdf/ClosedFileInputSource.cc
+++ b/libqpdf/ClosedFileInputSource.cc
@@ -4,16 +4,14 @@
ClosedFileInputSource::Members::Members(char const* filename) :
filename(filename),
offset(0),
- fis(0)
+ fis(0),
+ stay_open(false)
{
}
ClosedFileInputSource::Members::~Members()
{
- if (fis)
- {
- delete fis;
- }
+ delete fis;
}
ClosedFileInputSource::ClosedFileInputSource(char const* filename) :
@@ -42,6 +40,10 @@ ClosedFileInputSource::after()
{
this->last_offset = this->m->fis->getLastOffset();
this->m->offset = this->m->fis->tell();
+ if (this->m->stay_open)
+ {
+ return;
+ }
delete this->m->fis;
this->m->fis = 0;
}
@@ -82,6 +84,10 @@ void
ClosedFileInputSource::rewind()
{
this->m->offset = 0;
+ if (this->m->fis)
+ {
+ this->m->fis->rewind();
+ }
}
size_t
@@ -101,3 +107,13 @@ ClosedFileInputSource::unreadCh(char ch)
// Don't call after -- the file has to stay open after this
// operation.
}
+
+void
+ClosedFileInputSource::stayOpen(bool val)
+{
+ this->m->stay_open = val;
+ if ((! val) && this->m->fis)
+ {
+ after();
+ }
+}