Is it possible to check for a missing EOF?
I have a program that uses data files to store data and it reads and writes from the files with no problems at all, however I occassionally get an issue if the program is killed whilst writing out a data file this results in the EOF never being written and the program effectively getting stuck the next time it attempts to read in the file.
I create backup files and I do various checks on the data files to make sure they contain valid fields and automatically restore back the last good version if a problem is found, but the problem I have is that these checks also cause the program to enter the loop when the EOF is missing.
The datafiles can be anywhere from a few bytes to hundreds of megabytes in size, so I cannot rely on a counter to break me out of the loop at a fixed point as this could still only be part of the way through a large file.
Any ideas on how best to check for this error would be greatly appreciated.