After reading the specs on the STL file format, I want to write a few tests to ensure that a file is, in fact, a valid binary or ASCII file.
An ASCII-based STL file
Are there additional steps that would prove useful in validating whether I can be "absolutely sure" that a file is either ASCII or binary?
Since there is no format tag in the stl specs, you can't be absolutely sure about the file format.
Checking for "solid" in the beginning of the file should be enough in most cases. Additionally you could check for further keywords like "facet" or "vertex" to be sure it's ASCII. These words should only occur in the ASCII format (or in the useless binary header), but there is a little chance that the binary floats coincidentally form these words. So you could also check if the keywords are in the right order.
And of course check if the length in the binary header matches the file length.
But: Your code would work faster if you'd read the file linear and hope that nobody puts the words "solid" in the binary header. Maybe you should prefer ASCII-parsing if the file starts with "solid" and use the binary parser as a fallback if the ASCII parsing fails.