diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-12 22:34:04 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-20 20:04:21 +0200 |
| commit | 05bfa3d1fe9e274ed195647c6f74cb272f00c23d (patch) | |
| tree | 1372760463b288ff4e10ef7fb6e7414e202829f5 /src/mono_picture_frame.cc | |
| parent | 0338e7a7c19617f9ebb64ee02fbf3cceab8cf03f (diff) | |
Add and use new File class.master
It was always a bit troubling that fopen_boost wasn't exception safe,
and this also fixes a leak where load_ratings_list would never close
the ratings file.
Diffstat (limited to 'src/mono_picture_frame.cc')
| -rw-r--r-- | src/mono_picture_frame.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc index df75126c..ddaed983 100644 --- a/src/mono_picture_frame.cc +++ b/src/mono_picture_frame.cc @@ -41,6 +41,7 @@ #include "compose.hpp" #include "crypto_context.h" #include "exceptions.h" +#include "file.h" #include "j2k_transcode.h" #include "mono_picture_frame.h" #include "rgb_xyz.h" @@ -60,15 +61,12 @@ MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path) { auto const size = boost::filesystem::file_size (path); _buffer.reset(new ASDCP::JP2K::FrameBuffer(size)); - auto f = fopen_boost (path, "rb"); + File f(path, "rb"); if (!f) { boost::throw_exception (FileError("could not open JPEG2000 file", path, errno)); } - size_t n = fread (data(), 1, size, f); - fclose (f); - - if (n != size) { + if (f.read(data(), 1, size) != size) { boost::throw_exception (FileError("could not read from JPEG2000 file", path, errno)); } |
