Friday, February 10, 2006
Robust file output
A user called 'left' asked (on the SmartEiffel mailing list) how to do robust stream output. None of the put_xxx features, being commands, report any error status.
Berend de Boer offered a solution that is applicable to any compiler supported by his e-POSIX package:
Berend de Boer offered a solution that is applicable to any compiler supported by his e-POSIX package:
Use eposix. By default it raises an exception when an error occurs, but you can turn that off on a global or per object basis.
If turned off, check the object's errno.is_ok value. The errno.value property returns the last error, errno.first_value returns the first error that occurred. Be aware that errno.value and errno.first_value are system wide values, so check them as soon as possible.