Re: Reading binary files of irregular format with TMemoryStream
- From: "Robert Kilroy" <kilroy@xxxxxxxxx>
- Date: 12 Apr 2005 08:08:58 -0700
Thanks for the input guys. I appreciate it.
One thing that troubles me is the field data itself. For example, what
if I am told that a field is 4 bytes in length and somehow it gets
chopped to 2? If I go in with a for/next loop and read 4 bytes, then
I've read in the 2 byte field ID as well thinking its part of the data.
I know there's nothing I can do about that, it'll just be bad data. But
I have to process 700-1000 files at a time. I just need to make sure my
process doesn't crash.
I think checking for the position/size in the While/Do is just what I
was looking for.
I'm getting a copy of a corrupted file sent to me so I can inspect it a
bit more. All of the data in these files is binary. It works like this:
100 0 6 82 79 66 69 82 84
101 0 6 75 73 76 82 79 89
255 255
The above would tell me that field ID 100 is 6 characters long. I get
the ORD values of each byte after to get the letters. So that would
translate to:
100 =ROBERT
101=KILROY
I'm not sure how the files can get corrupted, but they have. So I guess
my main concern is just to know when I get to the end of the file and
let the chips fall where they may.
I think a problem I have is if I do a for/next loop to read 6 bytes and
I reach the end of the file prematurely can I recover?
But you have given me a direction to go in and I appreciate the help!
Robert Kilroy
.
- Follow-Ups:
- Re: Reading binary files of irregular format with TMemoryStream
- From: Maarten Wiltink
- Re: Reading binary files of irregular format with TMemoryStream
- From: alanglloyd@xxxxxxx
- Re: Reading binary files of irregular format with TMemoryStream
- From: Bruce Roberts
- Re: Reading binary files of irregular format with TMemoryStream
- References:
- Reading binary files of irregular format with TMemoryStream
- From: Robert Kilroy
- Re: Reading binary files of irregular format with TMemoryStream
- From: alanglloyd@xxxxxxx
- Reading binary files of irregular format with TMemoryStream
- Prev by Date: Re: Reading binary files of irregular format with TMemoryStream
- Next by Date: Re: Reading binary files of irregular format with TMemoryStream
- Previous by thread: Re: Reading binary files of irregular format with TMemoryStream
- Next by thread: Re: Reading binary files of irregular format with TMemoryStream
- Index(es):
Relevant Pages
|