Is the file stream pointer at end-of-file at some point? |
I believe it is only at the very end once, at thats on line 86, which is the first read from the end of file. From there though, it moves backwards away from the end.
I did have a bug where it read past end of the file, because I wasn't seeking back to the beginning of the file in
read_f but with
this->file->seekg(0, this->file->beg);, it will always read from the beginning (and that can be confirmed with
this->file->tellg() returning 0 on line 54)
The total size of "bin/windows.exe" is 7,721,015 bytes, the exe I am reading from withing is 7,720,960 bytes. So, in theory, when reading the full 7,720,960 bytes it shouldn't read over the end of the file (that's assuming the
read_from_end_until_null isn't ""removing"" data from the file, but that seems unlikely)
after every stream operation you should be checking the stream state |
To be honest, my error handling doesn't do this.
When you say "stream state", do you mean the good / bad bit states? For now, I am going to assume "stream state" does mean those bits.
If I print the bits (order bad/good) on line 84, I get
0, 1. If I print them again on line 93, I get again
0, 1.
However, after the read_f (line 103), the bad/good bits are
0, 0, so am I correct in saying something has gone wrong?