FACT++  1.0
bool zofits::writeCompressedDataToDisk ( char *  src,
const uint32_t  sizeToWrite 
)
inlineprotected

Actually does the writing to disk (and checksuming)

Parameters
srcthe buffer to write
sizeToWritehow many bytes should be written
Returns
the state of the file

Definition at line 656 of file zofits.h.

657  {
658  char* checkSumPointer = src+4;
659  int32_t extraBytes = 0;
660  uint32_t sizeToChecksum = sizeToWrite;
661 
662  //should we extend the array to the left ?
663  if (fCheckOffset != 0)
664  {
665  sizeToChecksum += fCheckOffset;
666  checkSumPointer -= fCheckOffset;
667  memset(checkSumPointer, 0, fCheckOffset);
668  }
669 
670  //should we extend the array to the right ?
671  if (sizeToChecksum%4 != 0)
672  {
673  extraBytes = 4 - (sizeToChecksum%4);
674  memset(checkSumPointer+sizeToChecksum, 0, extraBytes);
675  sizeToChecksum += extraBytes;
676  }
677 
678  //do the checksum
679  fDataSum.add(checkSumPointer, sizeToChecksum);
680 
681  fCheckOffset = (4 - extraBytes)%4;
682 
683  //write data to disk
684  write(src+4, sizeToWrite);
685 
686  return good();
687  }
Checksum fDataSum
Definition: ofits.h:340
int32_t fCheckOffset
offset to the data pointer to calculate the checksum
Definition: zofits.h:986
bool add(const char *buf, size_t len, bool big_endian=true)
Definition: checksum.h:49