Re: Writing Binary Files with TFileStream
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 24 Nov 2005 00:02:07 -0800
Unless you're originally reading from a file of someone else's making,
why not use what I call "long short strings" in the file.
These consist of an integer (4 bytes) specifying the length of the
string, followed by char-count (length) number of bytes.
Then delegate the actual reading to small functions which take a stream
parameter, and read and return an integer, and another which reads and
returns a string (reading the integer first and then the chars). And of
course the corresponding write procedures which take parameters of a
stream and what is to be written.
Such lower level delegating would help protect you from the error you
made. Very slightly slower -yes- but smoother coding.
Alan Lloyd
.
- Follow-Ups:
- Re: Writing Binary Files with TFileStream
- From: Nicholas Sherlock
- Re: Writing Binary Files with TFileStream
- References:
- Writing Binary Files with TFileStream
- From: Robert Kilroy
- Re: Writing Binary Files with TFileStream
- From: Robert Kilroy
- Re: Writing Binary Files with TFileStream
- From: alanglloyd@xxxxxxx
- Re: Writing Binary Files with TFileStream
- From: Robert Kilroy
- Writing Binary Files with TFileStream
- Prev by Date: Re: ASCII to UTF-8
- Next by Date: Re: Writing Binary Files with TFileStream
- Previous by thread: Re: Writing Binary Files with TFileStream
- Next by thread: Re: Writing Binary Files with TFileStream
- Index(es):