Skip to content

Commit 5131014

Browse files
committed
replace fopen with ofstream
Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent 78e2f2f commit 5131014

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/jp2image.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <algorithm>
2020
#include <array>
21+
#include <fstream>
2122
#include <iostream>
2223

2324
namespace Exiv2 {
@@ -218,13 +219,12 @@ void Jp2Image::readMetadata() {
218219
std::copy_n(data.c_data(pad), icc.size(), icc.begin());
219220
#ifdef EXIV2_DEBUG_MESSAGES
220221
const char* iccPath = "/tmp/libexiv2_jp2.icc";
221-
FILE* f = fopen(iccPath, "wb");
222-
if (f) {
223-
fwrite(icc.c_data(), icc.size(), 1, f);
224-
fclose(f);
222+
if (auto f = std::ofstream(iccPath, std::ios::binary)) {
223+
f.write(reinterpret_cast<const char*>(icc.c_data()), static_cast<std::streamsize>(icc.size()));
224+
f.close();
225+
std::cout << "Exiv2::Jp2Image::readMetadata: wrote iccProfile " << icc.size() << " bytes to " << iccPath
226+
<< '\n';
225227
}
226-
std::cout << "Exiv2::Jp2Image::readMetadata: wrote iccProfile " << icc.size() << " bytes to " << iccPath
227-
<< '\n';
228228
#endif
229229
setIccProfile(std::move(icc));
230230
}

0 commit comments

Comments
 (0)