- 17.01 (released) ...
A few classes of the Kernel Library support file manipulation, input and output: STD_FILES , FILE, DIRECTORY and UNIX_FILE_INFO . For simple applications it suffices to use STD_FILES , but to understand the concepts better it is preferable to look first at the other two.
FILE describes the notion of sequential file viewed as a data structure which fits in the general taxonomy of EiffelBase.
The class declaration defines files as unbounded sequences of characters. This means that you will find in FILE all the operations on sequential data structures that you have come to know and love by reading this documentation - at least, all that apply. Just as stacks and linked lists, files have
Queries are available to determine the status of a file, in particular
FILE is a deferred class. Various implementations are possible. A quite detailed one is PLAIN_TEXT_FILE, which adds many features for accessing reading and writing data from/to a file.
UNIX_FILE_INFO describes objects that contain internal information, such as protection mode and size, about a file.
The class DIRECTORY describes those files which are directories - nodes in the tree describing the file structure.
Basic input and output
Regardless of the operating system that you use, for simple input and output STD_FILES is sufficient. You may inherit from that class to gain direct access to its features; or you may declare an entity of type STD_FILES . But remember that a feature of this type is always available: io, from class ANY . Thanks to this feature you may include simple input and output in any class, with instructions such as
io.put_string ("My message")
STD_FILES defines three default files through features
To simplify the writing of common input and output operations, the most frequently used features of class FILE - for reading and writing integers, reals and so on, as discussed next - have been repeated in STD_FILES so as to apply to the default input and output. Procedure put_string in the example at the beginning of this section is typical: it writes its output on the standard output. More generally, STD_FILES has all the
- Parent <EiffelBase, The Kernel>