Changeset 13998 for trunk


Ignore:
Timestamp:
05/31/12 15:32:00 (12 years ago)
Author:
lyard
Message:
added the computation of the primary header checksum
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/ofits.h

    r13987 r13998  
    608608        h.SetInt ("NAXIS",     0, "number of data axes");
    609609        h.SetBool("EXTEND", true, "FITS dataset may contain extensions");
    610         h.SetStr ("CHECKSUM","4AcB48bA4AbA45bA", "Checksum for the whole HDU");
     610        h.SetStr ("CHECKSUM","0000000000000000", "Checksum for the whole HDU");
    611611        h.SetStr ("DATASUM", "         0", "Checksum for the data block");
    612612        h.AddComment("FITS (Flexible Image Transport System) format is defined in 'Astronomy");
     
    614614        h.End();
    615615
    616         return h.WriteHeader(*this);
     616        Checksum sum = h.WriteHeader(*this);
     617        size_t offset = tellp();
     618        h.SetStr("CHECKSUM", sum.str());
     619        //header gets updated here. cannot direcly return this otherwise
     620        //1. wrong checksum would be returned (does not matter... now)
     621        //2. cannot restore the correct location of the file's cursor
     622        h.WriteHeader(*this);
     623        seekp(offset);
     624        return sum;
    617625    }
    618626
Note: See TracChangeset for help on using the changeset viewer.