Jump to content
  • Advertisement
Sign in to follow this  
Low Bias

Best Way To Deal With Binary Files?

This topic is 5447 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
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! :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!