Add SMPTE Bv2.1 ExtensionMetadata.
[libdcp.git] / src / encrypted_kdm.cc
index 071bf87090596f6b2dad69899423a58183683271..e8e8987085014297831f97880c2edcd90c783272 100644 (file)
@@ -707,9 +707,15 @@ void
 EncryptedKDM::as_xml (boost::filesystem::path path) const
 {
        FILE* f = fopen_boost (path, "w");
+       if (!f) {
+               throw FileError ("Could not open KDM file for writing", path, errno);
+       }
        string const x = as_xml ();
-       fwrite (x.c_str(), 1, x.length(), f);
+       size_t const written = fwrite (x.c_str(), 1, x.length(), f);
        fclose (f);
+       if (written != x.length()) {
+               throw FileError ("Could not write to KDM file", path, errno);
+       }
 }
 
 string