Best Way To Deal With Binary Files?

Started by
12 comments, last by Low Bias 19 years, 7 months ago
Quote:Original post by Low Bias
Hey, Doynax! I was just in Sweden this past weekend! :)

Neat, you didn't stop by the northern region by any chance?
Can't say I've been to Canada though, not even close..
Advertisement
Keep in mind that structs may be padded for memory alignmnent; you cannot rely on the assumption that all fields are strictly sequential in memory (unless you disable struct padding, which is not necessarily a good idea and is, additionally, non-portable). It is much safer to read member by member.
Quote:Original post by Miserable
Keep in mind that structs may be padded for memory alignmnent; you cannot rely on the assumption that all fields are strictly sequential in memory (unless you disable struct padding, which is not necessarily a good idea and is, additionally, non-portable). It is much safer to read member by member.
Shouldn't be a problem for a char-only array though, but yeah.
Eighter you disable padding (#pragma pack..) and assume a fixed endianness or convert everything manually. But then some of the point of memory mapped files is lost.

It will always work with custom file formats though. So if you convert everything into your own format (as most games tend to do) you can still receive the performance benefits.

BTW, most file formats are properly aligned.

I guess I'm just promoting lazyness here. Still, that's not always a bad thing eighter ;)
Quote:Original post by doynax
Quote:Original post by Low Bias
Hey, Doynax! I was just in Sweden this past weekend! :)

Neat, you didn't stop by the northern region by any chance?
Can't say I've been to Canada though, not even close..


No, I was only in Stockholm. Beautiful country from what little I saw of it. :)

Thanks for all the help. I'll read all of this is and will get something great from it.

You're right though. Why do I nee to treat them as null terminated strings at all? As long as I only look at as many elements of the character array as I'm concerned with, right?

Thanks! :)

This topic is closed to new replies.

Advertisement