mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Split QPDF member file into file and file_sp to facilitate aliasing
To be encapsulated later.
This commit is contained in:
parent
db06e075ea
commit
b1d845e708
@ -198,7 +198,8 @@ QPDF::EncryptionParameters::EncryptionParameters() :
|
|||||||
|
|
||||||
QPDF::Members::Members(QPDF& qpdf) :
|
QPDF::Members::Members(QPDF& qpdf) :
|
||||||
log(QPDFLogger::defaultLogger()),
|
log(QPDFLogger::defaultLogger()),
|
||||||
file(new InvalidInputSource()),
|
file_sp(new InvalidInputSource()),
|
||||||
|
file(file_sp.get()),
|
||||||
encp(new EncryptionParameters),
|
encp(new EncryptionParameters),
|
||||||
xref_table(qpdf)
|
xref_table(qpdf)
|
||||||
{
|
{
|
||||||
@ -272,14 +273,16 @@ QPDF::processMemoryFile(
|
|||||||
void
|
void
|
||||||
QPDF::processInputSource(std::shared_ptr<InputSource> source, char const* password)
|
QPDF::processInputSource(std::shared_ptr<InputSource> source, char const* password)
|
||||||
{
|
{
|
||||||
m->file = source;
|
m->file_sp = source;
|
||||||
|
m->file = source.get();
|
||||||
parse(password);
|
parse(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF::closeInputSource()
|
QPDF::closeInputSource()
|
||||||
{
|
{
|
||||||
m->file = std::shared_ptr<InputSource>(new InvalidInputSource());
|
m->file_sp = std::shared_ptr<InputSource>(new InvalidInputSource());
|
||||||
|
m->file = m->file_sp.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -412,7 +415,9 @@ QPDF::findHeader()
|
|||||||
// PDF header, all explicit offsets in the file are such that 0 points to the beginning
|
// PDF header, all explicit offsets in the file are such that 0 points to the beginning
|
||||||
// of the header.
|
// of the header.
|
||||||
QTC::TC("qpdf", "QPDF global offset");
|
QTC::TC("qpdf", "QPDF global offset");
|
||||||
m->file = std::shared_ptr<InputSource>(new OffsetInputSource(m->file, global_offset));
|
m->file_sp =
|
||||||
|
std::shared_ptr<InputSource>(new OffsetInputSource(m->file_sp, global_offset));
|
||||||
|
m->file = m->file_sp.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
@ -1541,7 +1546,7 @@ QPDF::readStream(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offset)
|
|||||||
} catch (QPDFExc& e) {
|
} catch (QPDFExc& e) {
|
||||||
if (m->attempt_recovery) {
|
if (m->attempt_recovery) {
|
||||||
warn(e);
|
warn(e);
|
||||||
length = recoverStreamLength(m->file, og, stream_offset);
|
length = recoverStreamLength(m->file_sp, og, stream_offset);
|
||||||
} else {
|
} else {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -2452,7 +2457,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
|||||||
} else {
|
} else {
|
||||||
auto foreign_stream_data = std::make_shared<ForeignStreamData>(
|
auto foreign_stream_data = std::make_shared<ForeignStreamData>(
|
||||||
foreign_stream_qpdf.m->encp,
|
foreign_stream_qpdf.m->encp,
|
||||||
foreign_stream_qpdf.m->file,
|
foreign_stream_qpdf.m->file_sp,
|
||||||
foreign.getObjGen(),
|
foreign.getObjGen(),
|
||||||
stream->getParsedOffset(),
|
stream->getParsedOffset(),
|
||||||
stream->getLength(),
|
stream->getLength(),
|
||||||
@ -2776,7 +2781,7 @@ QPDF::pipeStreamData(
|
|||||||
{
|
{
|
||||||
return pipeStreamData(
|
return pipeStreamData(
|
||||||
m->encp,
|
m->encp,
|
||||||
m->file,
|
m->file_sp,
|
||||||
*this,
|
*this,
|
||||||
og,
|
og,
|
||||||
offset,
|
offset,
|
||||||
|
@ -528,7 +528,9 @@ class QPDF::Members
|
|||||||
std::shared_ptr<QPDFLogger> log;
|
std::shared_ptr<QPDFLogger> log;
|
||||||
unsigned long long unique_id{0};
|
unsigned long long unique_id{0};
|
||||||
QPDFTokenizer tokenizer;
|
QPDFTokenizer tokenizer;
|
||||||
std::shared_ptr<InputSource> file;
|
// If file_sp is updated, file must also be updated.
|
||||||
|
std::shared_ptr<InputSource> file_sp;
|
||||||
|
InputSource* file;
|
||||||
std::string last_object_description;
|
std::string last_object_description;
|
||||||
bool provided_password_is_hex_key{false};
|
bool provided_password_is_hex_key{false};
|
||||||
bool suppress_warnings{false};
|
bool suppress_warnings{false};
|
||||||
|
Loading…
Reference in New Issue
Block a user