From ac4deac1873ca1bb570ffd479ed2cc1010762f89 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 28 Feb 2013 16:45:11 -0500 Subject: 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. --- libqpdf/FileInputSource.cc | 3 +-- libqpdf/MD5.cc | 5 +---- libqpdf/QPDFWriter.cc | 3 +-- libqpdf/QTC.cc | 4 +--- libqpdf/QUtil.cc | 7 +++++++ 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc index 0cd0ef96..ef259c4c 100644 --- a/libqpdf/FileInputSource.cc +++ b/libqpdf/FileInputSource.cc @@ -15,8 +15,7 @@ FileInputSource::setFilename(char const* filename) destroy(); this->filename = filename; this->close_file = true; - this->file = QUtil::fopen_wrapper(std::string("open ") + this->filename, - fopen(this->filename.c_str(), "rb")); // XXXX + this->file = QUtil::safe_fopen(this->filename.c_str(), "rb"); } void diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc index ff812f35..0504e2d4 100644 --- a/libqpdf/MD5.cc +++ b/libqpdf/MD5.cc @@ -328,10 +328,7 @@ void MD5::encodeFile(char const *filename, int up_to_size) { unsigned char buffer[1024]; - FILE *file = QUtil::fopen_wrapper( - std::string("MD5: open ") + filename, - fopen(filename, "rb")); // XXXX - + FILE *file = QUtil::safe_fopen(filename, "rb"); size_t len; int so_far = 0; int to_try = 1024; diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 96f50c13..82976452 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -104,8 +104,7 @@ QPDFWriter::setOutputFilename(char const* filename) else { QTC::TC("qpdf", "QPDFWriter write to file"); - f = QUtil::fopen_wrapper(std::string("open ") + filename, - fopen(filename, "wb+")); // XXXX + f = QUtil::safe_fopen(filename, "wb+"); close_file = true; } setOutputFile(description, f, close_file); diff --git a/libqpdf/QTC.cc b/libqpdf/QTC.cc index c1d863e6..cbaf558b 100644 --- a/libqpdf/QTC.cc +++ b/libqpdf/QTC.cc @@ -37,9 +37,7 @@ void QTC::TC(char const* const scope, char const* const ccase, int n) } cache.insert(std::make_pair(ccase, n)); - FILE* tc = - QUtil::fopen_wrapper("open test coverage file (" + filename + ")", - fopen(filename.c_str(), "ab")); // XXXX + FILE* tc = QUtil::safe_fopen(filename.c_str(), "ab"); fprintf(tc, "%s %d\n", ccase, n); fclose(tc); } diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index f186389d..b7cdb9b2 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -109,6 +109,13 @@ QUtil::os_wrapper(std::string const& description, int status) return status; } +FILE* +QUtil::safe_fopen(char const* filename, char const* mode) +{ + return fopen_wrapper(std::string("open ") + filename, + fopen(filename, mode)); // XXXX +} + FILE* QUtil::fopen_wrapper(std::string const& description, FILE* f) { -- cgit v1.2.3-70-g09d2