I have an app that collects performance data for a network of radio modems. It runs for days writing to a file about once a second using a method having these two lines:

  FAstream.WriteDouble v
  FAstream.WritePString s

When the app is quit and started again later it's supposed to pick up where it left off, appending data to the end of the file. It does that just fine. The problem is when the data is analyzed later, the file is found to be corrupt. I tracked this down to the point where the app is quit and restarted. It seems that the last WritePString that was executed prior to closing the file writes the length byte but not the string itself.

This is a typical line from the WriteDouble and WritePString code (the 1st 8 bytes are the double and the remainder is the Pstring):

41 E8 2B 2D 1F 20 00 00 2C F5 11 01 12 34 56 78 9A BC DE F0 76 00 00 00 00 00 00 00 08 00 00 22 00 00 1D 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 F9 BB

That 9th byte, the 2C, is the length byte for the Pstring. The length is always 2C bytes. At the end of a closed file this is what's there:

41 E8 2B 2D 1F 40 00 00 2C (eof)

The double, and the length byte of the Pstring, but no data.

Can anyone shed any light on this?

-Richard
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to