Skip to main content
GameDev.net gamedev.net
🔒 Locked

Error proofing reading files with fstream

Started by jonboym Oct 25, 2004 at 10:34 AM 0 replies 1k views
Original Post
jonboym
jonboym
Hi, I'm building an IO class based on the one in the Enginuity series but using fstreams instead of the c functions (fopen etc). One thing I would like to do is add in error proofing/checking so that my class will flag up any appropriate problems. I'm trying to decide if its best to this by return types (ie return false or an error code if something goes wrong) or whether to throw an exception. Opinions? The other thing I was wondering is how to check I'm reading the correct data. I can check the length of the file matches what is expected but wondered if there was a better way. I suppose I'm looking for ideas on creating file formats and how to check a particular file i read in is formatted correctly with all the data in the right order. Any references to online articles or books etc would be appreciated. Thanks Jon
vNistelrooy
vNistelrooy
Quote:
Original post by jonboym
The other thing I was wondering is how to check I'm reading the correct data. I can check the length of the file matches what is expected but wondered if there was a better way. I suppose I'm looking for ideas on creating file formats and how to check a particular file i read in is formatted correctly with all the data in the right order. Any references to online articles or books etc would be appreciated.

Jon


Read whatever you want 10 times, then compare all the read data, chose the data that was read most times. [rolleyes]
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.