Changeset b248ca for molecuilder


Ignore:
Timestamp:
Oct 15, 2008, 6:20:40 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
93d0ee
Parents:
a7e452
Message:

new function AppendOutputFile() for appending to output files whereas with OpenOutputFile the contents is deleted.

Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/datacreator.cpp

    ra7e452 rb248ca  
    2222  name << dir << "/" << filename;
    2323  output.open(name.str().c_str(), ios::out);
     24  if (output == NULL) {
     25    cout << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;
     26    return false;
     27  }
     28  return true;
     29};
     30
     31/** Opens a file for appending with \a *filename in \a *dir.
     32 * \param output file handle on return
     33 * \param *dir directory
     34 * \param *filename name of file
     35 * \return true if file has been opened
     36 */
     37bool AppendOutputFile(ofstream &output, const char *dir, const char *filename)
     38{
     39  stringstream name;
     40  name << dir << "/" << filename;
     41  output.open(name.str().c_str(), ios::app);
    2442  if (output == NULL) {
    2543    cout << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;
     
    231249    Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.);
    232250    // errors per atom
    233     output << "#Order\t" << BondOrder+1 << endl;
     251    output << endl << "#Order\t" << BondOrder+1 << endl;
    234252    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    235253      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
  • molecuilder/src/datacreator.hpp

    ra7e452 rb248ca  
    1818
    1919bool OpenOutputFile(ofstream &output, const char *dir, const char *filename);
     20bool AppendOutputFile(ofstream &output, const char *dir, const char *filename);
    2021
    2122bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum);
Note: See TracChangeset for help on using the changeset viewer.