Recommended Posts

This is really messed up....
I've been working on a resource file packing mechanism, and it works great, but I've noticed some... odd... behaviour when I ran it on Windows. I ran the exact same code on the exact same set of files, with the following differences:
- The resource file in windows is exactly 1 byte larger than the one generated in Linux
- I've verified that the two files are exactly identical, except for the one last byte appended by the windows code
Now, this is where it gets weird:
- When reading the resource file, both windows and linux can only handle the one generated in linux.
The reason this is so weird is that since the files are exactly the same (except the last trailing byte), it should be able to read in the header information fine, which it does not. Is there something shady going on on the windows side? I'm using Dev-C++, fwiw.
Thanks

Edit: yup, out of (seemingly) nowhere, it inserts a 0x0d just ONCE. I'll debug it some other time with toy data.... ugh...More edit: In fact, it looks like the windows version is throwing in lots of padding here and there, just for the hell of it.

Share this post

Link to post

Share on other sites

Original post by SneftelRead and write in binary mode. If you don't know what that means, look it up.

Heh yeah, I should probably switch it over to the fstream implementations of read/write and use ios::binary. I'm currently on the C API. Interestingly, there is an "O_BINARY" flag available using the libraries that come with Dev-C++, but my linux box doesn't define that flag. No wonder it doesn't show up on the man pages. So, I guess there's no choice - if I don't move it to fstream, the code won't be cross-platform, so the switch will happen sooner rather than later. Thanks for the tips.