Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

10.2 RWFile

Class RWFile is an abstraction of a file system's file. The interface for this class is based on class PFile of the Interviews Class Library (Stanford University, 1987), but has been modernized by Rogue Wave to use const modifiers, and to port to various operating systems. The member function names begin with upper case letters in order to maintain compatibility with class PFile.

There are member functions to flush the file, and to test whether the file operation has an error, is empty, or at the end-of-file.

10.2.1 Example

Class RWFile also has member functions to determine the status of a file, and to read and write a wide variety of built-in types, either one at a time, or as arrays. The file pointer may be repositioned with functions SeekTo(), SeekTo64() (for large files greater than 2gb), SeekToBegin(), and SeekToEnd(). The details of the RWFile class capabilities are summarized in the SourcePro C++ API Reference Guide.

The following example creates an RWFile object with filename test.dat. If the file is not empty, the code reads an int, increments it, and writes it back to the file. Otherwise, it writes the value 1 to the file.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.