fstream_namd.C

Go to the documentation of this file.
00001 
00002 #include "fstream_namd.h"
00003 #include "common.h"
00004 
00005 void ofstream_namd::open(const char *_fname, const char *_ext) {
00006   if ( fd ) NAMD_bug("ofstream_namd::open() called when file is already open");
00007   NAMD_backup_file(_fname, _ext);
00008   open(_fname);
00009 }
00010 
00011 void ofstream_namd::open(const char *_fname, std::ios_base::openmode _mode) {
00012   if ( fd ) NAMD_bug("ofstream_namd::open() called when file is already open");
00013   fname = _fname;
00014   fd = NAMD_open_text(_fname, _mode & std::ios_base::app);
00015 }
00016 
00017 ofstream_namd& ofstream_namd::flush() {
00018   if ( ! fd ) NAMD_bug("ofstream_namd::flush() called when file is not open");
00019   const std::string text = str();
00020   NAMD_write(fd, text.c_str(), text.size(), fname.c_str());
00021   str("");
00022   return *this;
00023 }
00024 
00025 void ofstream_namd::close() {
00026   if ( ! fd ) NAMD_bug("ofstream_namd::close() called when file is not open");
00027   flush();
00028   NAMD_close(fd, fname.c_str());
00029   fd = 0;
00030 }
00031 

Generated on Mon Nov 20 01:17:12 2017 for NAMD by  doxygen 1.4.7