]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/props_io.cxx
Added a touch of error checking to the screen dump routine, i.e. don't
[simgear.git] / simgear / misc / props_io.cxx
index 8515fc7318378670ebf10914296241b0a5d49e20..35c282f6e73f76cced617ab943cc59df6f5c9557 100644 (file)
@@ -9,10 +9,12 @@
 #include "props.hxx"
 
 #include <iostream>
+#include <fstream>
 #include <string>
 #include <vector>
 
 using std::istream;
+using std::ifstream;
 using std::ostream;
 using std::string;
 using std::vector;
@@ -221,6 +223,19 @@ readPropertyList (istream &input, SGPropertyList * props)
   return readXML(input, visitor) && visitor.isOK();
 }
 
+bool
+readPropertyList (const string &file, SGPropertyList * props)
+{
+  ifstream input(file.c_str());
+  if (input.good()) {
+    return readPropertyList(input, props);
+  } else {
+    FG_LOG(FG_INPUT, FG_ALERT, "Error reading property list from file "
+          << file);
+    return false;
+  }
+}
+
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -330,3 +345,16 @@ writePropertyList (ostream &output, const SGPropertyList * props)
 
   output << "</PropertyList>" << endl;
 }
+
+bool
+writePropertyList (const string &file, const SGPropertyList * props)
+{
+  ofstream output(file.c_str());
+  if (output.good()) {
+    return writePropertyList(output, props);
+  } else {
+    FG_LOG(FG_INPUT, FG_ALERT, "Cannot write property list to file "
+          << file);
+    return false;
+  }
+}