Files are automatically opened in `r' or `w' mode if a stream input or output operation is initiated on a previously unmentioned name. For an auto-opened input file, when an end-of-file condition is sensed, the stream is auto-closed. The only routine which auto-closes a stream that was auto-opened for output is putfile, making it a partner to getfile in using the environmental filesystem as an elementary persistent database.
In order to discover whether a particular stream is open (either as a result of automatic opening or a successful open call), the boolean-valued expression *
is_open fcan be applied to a filename or file descriptor f without causing any side-effects such as the setting of last_error.