aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/flate.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-02-28 22:45:11 +0100
committerJay Berkenbilt <ejb@ql.org>2013-03-05 19:35:46 +0100
commitac4deac1873ca1bb570ffd479ed2cc1010762f89 (patch)
treee83f1d756f161b799483926676446241fc8ffeed /libtests/flate.cc
parent7ccc9bd9d5463d29f3fc19a7f7718842e3b68be8 (diff)
downloadqpdf-ac4deac1873ca1bb570ffd479ed2cc1010762f89.tar.zst
Call QUtil::safe_fopen in place of fopen
fopen was previuosly called wrapped by QUtil::fopen_wrapper, but QUtil::safe_fopen does this itself, which is less cumbersome.
Diffstat (limited to 'libtests/flate.cc')
-rw-r--r--libtests/flate.cc23
1 files changed, 6 insertions, 17 deletions
diff --git a/libtests/flate.cc b/libtests/flate.cc
index d5f77162..a6d4eeb6 100644
--- a/libtests/flate.cc
+++ b/libtests/flate.cc
@@ -2,33 +2,22 @@
#include <qpdf/Pl_Flate.hh>
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/Pl_Count.hh>
+#include <qpdf/QUtil.hh>
#include <iostream>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
-FILE* safe_fopen(char const* filename, char const* mode)
-{
- FILE* result = fopen(filename, mode); // XXXX
- if (result == 0)
- {
- std::cerr << "fopen " << filename << " failed: " << strerror(errno) // XXXX
- << std::endl;
- exit(2);
- }
- return result;
-}
-
void run(char const* filename)
{
std::string n1 = std::string(filename) + ".1";
std::string n2 = std::string(filename) + ".2";
std::string n3 = std::string(filename) + ".3";
- FILE* o1 = safe_fopen(n1.c_str(), "wb");
- FILE* o2 = safe_fopen(n2.c_str(), "wb");
- FILE* o3 = safe_fopen(n3.c_str(), "wb");
+ FILE* o1 = QUtil::safe_fopen(n1.c_str(), "wb");
+ FILE* o2 = QUtil::safe_fopen(n2.c_str(), "wb");
+ FILE* o3 = QUtil::safe_fopen(n3.c_str(), "wb");
Pipeline* out1 = new Pl_StdioFile("o1", o1);
Pipeline* out2 = new Pl_StdioFile("o2", o2);
Pipeline* out3 = new Pl_StdioFile("o3", o3);
@@ -46,7 +35,7 @@ void run(char const* filename)
Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate);
Pipeline* def3 = new Pl_Flate("def3", inf3, Pl_Flate::a_deflate);
- FILE* in1 = safe_fopen(filename, "rb");
+ FILE* in1 = QUtil::safe_fopen(filename, "rb");
unsigned char buf[1024];
size_t len;
while ((len = fread(buf, 1, sizeof(buf), in1)) > 0)
@@ -75,7 +64,7 @@ void run(char const* filename)
fclose(o3);
// Now read the compressed data and write to the output uncompress pipeline
- FILE* in2 = safe_fopen(n1.c_str(), "rb");
+ FILE* in2 = QUtil::safe_fopen(n1.c_str(), "rb");
while ((len = fread(buf, 1, sizeof(buf), in2)) > 0)
{
inf2->write(buf, len);