diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-12 22:34:04 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-12 22:34:04 +0200 |
| commit | c83f348adce3a18a9144ecfd73f4629cf060cc2a (patch) | |
| tree | 5528c60440343b547c15f4a95aa6acd06453fafe /src/mono_picture_frame.cc | |
| parent | 04e215a7688239cb47fc86e8396756c685f338a1 (diff) | |
Add and use new File class.merged-to-main
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)); } |
