]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
write file automatically
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 2 Feb 2000 01:59:00 +0000 (01:59 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 2 Feb 2000 01:59:00 +0000 (01:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@2315 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/parameter_handler.h
deal.II/base/source/parameter_handler.cc

index a90ce0b4dbde3372db242abddaed1c7e6c284e2e..1f6f0be22e8983a909c8a0533d8a4495dcb17c7d 100644 (file)
@@ -643,6 +643,10 @@ class ParameterHandler
                                      * is given.
                                      *
                                      * Return whether the read was successful.
+                                     *
+                                     * This function will automatically generate
+                                     * the requested file with default values if
+                                     * the file did not exist.
                                      */
     virtual bool read_input (const string &filename);
     
index e851a40fd6bfdb1d94f5097c3636ab34a046fdcd..f2f5ee5452f43d192cf54275e6b0196a2dc4ba3e 100644 (file)
@@ -239,17 +239,27 @@ bool ParameterHandler::read_input (istream &input) {
 };
 
 
-bool ParameterHandler::read_input (const string &filename) {
+bool ParameterHandler::read_input (const string &filename)
+{
   ifstream input (filename.c_str());
   if (!input) 
     {
       cerr << "ParameterHandler::read_input: could not open file <"
-          << filename << ">. Aborting." << endl;
+          << filename << "> for reading." << endl
+          << "Trying to make file ;<"
+          << filename << "> with default values for you." << endl;
+
+      ofstream output (filename.c_str());
+      if (output)
+       {
+         print_parameters (output, Text);
+       }
+      
       return false;
-    };
+    }
   
   return read_input (input);
-};
+}
 
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.