Data access is provided through the Open Class streaming classes.
IFileIOStream is a standard library-style stream class that can be constructed from an IFile. It allows iostream-based code to interoperate with the file system API. To perform I/O operations, you use the functions inherited from iostream. Use IFileIOStream when you need compatibility with the standard iostream classes or access to legacy data that is stored in files. You use this class almost exactly the same way you would the standard fstream class, except that the constructor accepts an IFile argument.
IDataStream is the standard Open Class stream for C++ objects. Use IDataStream to store persistent objects, Open Class documents, and other object-based data.
The constructors for both of the stream classes take two int arguments, modeForMe and modeForOthers, that determine how the file is opened. The first argument specifies the type of access that you want to have to the stream yourself, plus any special behavior that you want when the file is opened. The second argument specifies the access that you want to allow for others who try to open the file when you already have it open.
The int values for both of these arguments are constructed by combining the open_mode constants from the ios class or the EOpenMode constants from the IFile class. The constants that specify access levels are as follows:
There are a few other open-mode constants that specify special behavior when you open or write to the file. These constants have no effect if they are added into the modeForOthers argument.
Both IDataStream and IFileIOStream keep track of the end of the file, also called end of stream. As you write out a file stream, the end-of-file marker moves forward. To move the stream marker more efficiently, use IFileIOStream::seek to move the marker forward to the position you want.
Note: When you move the end-of-file marker forward, the results will depend on the host file system. Because your code might be used on different file systems, you need to code as though you risk running out of file space each time you move the end-of-file marker.
Introduction to the Streaming Classes
Introduction to the File
System
Files
File System Exceptions
Setting
Stream Access Permissions
Accessing
File Contents Using C++ Streams
Accessing
File Contents Using Open Class Streams