mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-16 01:27:07 +00:00
1e74c03acd
git-svn-id: svn+q:///qpdf/trunk@688 71b93d88-0707-0410-a8cf-f5a4172ac649
53 lines
779 B
C++
53 lines
779 B
C++
|
|
#include <qpdf/Pl_StdioFile.hh>
|
|
|
|
#include <errno.h>
|
|
|
|
DLL_EXPORT
|
|
Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
|
|
Pipeline(identifier, 0),
|
|
file(f)
|
|
{
|
|
}
|
|
|
|
DLL_EXPORT
|
|
Pl_StdioFile::~Pl_StdioFile()
|
|
{
|
|
}
|
|
|
|
DLL_EXPORT
|
|
void
|
|
Pl_StdioFile::write(unsigned char* buf, int len)
|
|
{
|
|
size_t so_far = 0;
|
|
while (len > 0)
|
|
{
|
|
so_far = fwrite(buf, 1, len, this->file);
|
|
if (so_far == 0)
|
|
{
|
|
throw QEXC::System(this->identifier + ": Pl_StdioFile::write",
|
|
errno);
|
|
}
|
|
else
|
|
{
|
|
buf += so_far;
|
|
len -= so_far;
|
|
}
|
|
}
|
|
}
|
|
|
|
DLL_EXPORT
|
|
void
|
|
Pl_StdioFile::finish()
|
|
{
|
|
if (fileno(this->file) != -1)
|
|
{
|
|
fflush(this->file);
|
|
}
|
|
else
|
|
{
|
|
throw QEXC::Internal(this->identifier +
|
|
": Pl_StdioFile::finish: stream already closed");
|
|
}
|
|
}
|