From 05bfa3d1fe9e274ed195647c6f74cb272f00c23d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Apr 2022 22:34:04 +0200 Subject: Add and use new File class. 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. --- src/interop_subtitle_asset.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interop_subtitle_asset.cc') diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index bb0cad70..798f1cda 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -40,6 +40,7 @@ #include "compose.hpp" #include "dcp_assert.h" #include "font_asset.h" +#include "file.h" #include "interop_load_font_node.h" #include "interop_subtitle_asset.h" #include "raw_convert.h" @@ -191,15 +192,14 @@ InteropSubtitleAsset::load_font_nodes () const void InteropSubtitleAsset::write (boost::filesystem::path p) const { - auto f = fopen_boost (p, "w"); + File f(p, "w"); if (!f) { throw FileError ("Could not open file for writing", p, -1); } _raw_xml = xml_as_string (); /* length() here gives bytes not characters */ - fwrite (_raw_xml->c_str(), 1, _raw_xml->length(), f); - fclose (f); + f.write(_raw_xml->c_str(), 1, _raw_xml->length()); _file = p; -- cgit v1.2.3