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/encrypted_kdm.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/encrypted_kdm.cc')
| -rw-r--r-- | src/encrypted_kdm.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index 986f82e4..5e5f9fe4 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -37,11 +37,12 @@ */ -#include "encrypted_kdm.h" -#include "util.h" #include "certificate_chain.h" -#include "exceptions.h" #include "compose.hpp" +#include "encrypted_kdm.h" +#include "exceptions.h" +#include "file.h" +#include "util.h" #include <libcxml/cxml.h> #include <libxml++/document.h> #include <libxml++/nodes/element.h> @@ -730,14 +731,12 @@ EncryptedKDM::~EncryptedKDM () void EncryptedKDM::as_xml (boost::filesystem::path path) const { - auto f = fopen_boost (path, "w"); + File f(path, "w"); if (!f) { throw FileError ("Could not open KDM file for writing", path, errno); } auto const x = as_xml (); - size_t const written = fwrite (x.c_str(), 1, x.length(), f); - fclose (f); - if (written != x.length()) { + if (f.write(x.c_str(), 1, x.length()) != x.length()) { throw FileError ("Could not write to KDM file", path, errno); } } |
