Fix fopen call and throw an exception if it fails.
authorCarl Hetherington <cth@carlh.net>
Fri, 4 Jul 2014 14:39:35 +0000 (15:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 4 Jul 2014 14:39:35 +0000 (15:39 +0100)
src/subtitle_content.cc

index 7e11dea4b20545f8d6d2412551072d6fefe7d3b3..5a45d7372164845889540e6072f716aebfba2672 100644 (file)
@@ -238,7 +238,11 @@ struct SubtitleSorter {
 void
 SubtitleContent::write_xml (boost::filesystem::path p) const
 {
-       FILE* f = fopen_boost (p, "r");
+       FILE* f = fopen_boost (p, "w");
+       if (!f) {
+               throw FileError ("Could not open file for writing", p, -1);
+       }
+       
        Glib::ustring const s = xml_as_string ();
        fwrite (s.c_str(), 1, s.length(), f);
        fclose (f);