diff options
author | Jay Berkenbilt <ejb@ql.org> | 2008-04-29 14:55:25 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2008-04-29 14:55:25 +0200 |
commit | 9a0b88bf7777c153dc46ace22db74ef24d51583a (patch) | |
tree | f567ac1cf2bf5071a611eb49323a935b6ac938ff /libqpdf/Pl_StdioFile.cc | |
download | qpdf-9a0b88bf7777c153dc46ace22db74ef24d51583a.tar.zst |
update release date to actual daterelease-qpdf-2.0
git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/Pl_StdioFile.cc')
-rw-r--r-- | libqpdf/Pl_StdioFile.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc new file mode 100644 index 00000000..c0f42afd --- /dev/null +++ b/libqpdf/Pl_StdioFile.cc @@ -0,0 +1,48 @@ + +#include <qpdf/Pl_StdioFile.hh> + +#include <errno.h> + +Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) : + Pipeline(identifier, 0), + file(f) +{ +} + +Pl_StdioFile::~Pl_StdioFile() +{ +} + +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; + } + } +} + +void +Pl_StdioFile::finish() +{ + if (fileno(this->file) != -1) + { + fflush(this->file); + } + else + { + throw QEXC::Internal(this->identifier + + ": Pl_StdioFile::finish: stream already closed"); + } +} |