I've made a function that retrieves filenames from a binary archive. It's part of the "Archive" class.
The filenames are, or rather should be, null-terminated, can be no longer than 255 characters and (tbd) must be ASCII characters.
If there is no filename and a null is the first character read, it's assumed to be EOF and the archive has been successfully read.
All I'm looking to do now is how to handle errors, handle success (EOF), and how to improve the readability and performance of the function.
Probably painfully obvious to the experts, but just want to check I'm on the right tracking with throw exceptions for both errors and success, and that everything else is alright.
Throwing exceptions makes so sense for successful operation. Exceptions are there to report problems.
Exceptions provide a way to react to exceptional circumstances (like runtime errors) in programs by transferring control to special functions called handlers.
reading 1 char at a time is a performance killer. So is testing for eof after each char.
If the file fits into ram, read it entirely and parse a memory buffer.
If the file is too big (and these days, that means over 10gb for even home systems, and 30-100+gb for commercial systems) read in large blocks (ideally, disk sector related sized blocks, but that is really going deep).