mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-04 20:37:50 +00:00
79f6b4823b
Have classes contain only a single private member of type PointerHolder<Members>. This makes it safe to change the structure of the Members class without breaking binary compatibility. Many of the classes already follow this pattern quite successfully. This brings in the rest of the class that are part of the public API.
57 lines
953 B
C++
57 lines
953 B
C++
#include <qpdf/qpdf-config.h> // include first for large file support
|
|
#include <qpdf/Pl_StdioFile.hh>
|
|
#include <qpdf/QUtil.hh>
|
|
#include <stdexcept>
|
|
#include <errno.h>
|
|
|
|
Pl_StdioFile::Members::Members(FILE* f) :
|
|
file(f)
|
|
{
|
|
}
|
|
|
|
Pl_StdioFile::Members::~Members()
|
|
{
|
|
}
|
|
|
|
Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
|
|
Pipeline(identifier, 0),
|
|
m(new Members(f))
|
|
{
|
|
}
|
|
|
|
Pl_StdioFile::~Pl_StdioFile()
|
|
{
|
|
}
|
|
|
|
void
|
|
Pl_StdioFile::write(unsigned char* buf, size_t len)
|
|
{
|
|
size_t so_far = 0;
|
|
while (len > 0)
|
|
{
|
|
so_far = fwrite(buf, 1, len, this->m->file);
|
|
if (so_far == 0)
|
|
{
|
|
QUtil::throw_system_error(
|
|
this->identifier + ": Pl_StdioFile::write");
|
|
}
|
|
else
|
|
{
|
|
buf += so_far;
|
|
len -= so_far;
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
Pl_StdioFile::finish()
|
|
{
|
|
if ((fflush(this->m->file) == -1) &&
|
|
(errno == EBADF))
|
|
{
|
|
throw std::logic_error(
|
|
this->identifier +
|
|
": Pl_StdioFile::finish: stream already closed");
|
|
}
|
|
}
|