FACT++  1.0
virtual bool ofits::close ( )
inlinevirtual

Reimplemented in zofits.

Definition at line 984 of file ofits.h.

References ___err___, AlignTo2880Bytes(), gLog, ofits::Table::num_rows, SetInt(), UpdateHeaderChecksum(), and Checksum::val().

Referenced by main(), SetDefaultKeys(), and ~ofits().

985  {
986  if (tellp()<0)
987  return false;
988 
990 
991  // We don't have to jump back to the end of the file
992  SetInt("NAXIS2", fTable.num_rows);
993 
994  const Checksum chk = UpdateHeaderChecksum();
995 
996  if (!fFilebuf.close())
997  setstate(ios_base::failbit);
998 
999  if ((chk+fDataSum).valid())
1000  return true;
1001 
1002  std::ostringstream sout;
1003  sout << "Checksum (" << std::hex << chk.val() << ") invalid.";
1004 #ifdef __EXCEPTIONS
1005  throw std::runtime_error(sout.str());
1006 #else
1007  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
1008  return false;
1009 #endif
1010  }
bool SetInt(const std::string &key, int64_t i, const std::string &comment="")
Definition: ofits.h:535
void AlignTo2880Bytes()
Definition: ofits.h:961
Checksum fDataSum
Definition: ofits.h:340
Checksum UpdateHeaderChecksum()
Definition: ofits.h:970
uint32_t val() const
Definition: checksum.h:20
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
Table fTable
Definition: ofits.h:327
std::filebuf fFilebuf
Definition: ofits.h:32
size_t num_rows
Definition: ofits.h:307

+ Here is the call graph for this function:

+ Here is the caller graph for this function: