#include <source/toolbox/stream/FileStream.h>
Inheritance diagram for SAMRAI::tbox::FileStream:
Public Types | |
enum | StreamMode { Read, Write, Append } |
Public Member Functions | |
FileStream (const char *filename, const StreamMode mode) | |
FileStream (FILE *file, const StreamMode mode) | |
virtual | ~FileStream () |
void | closeFileOnExit (const bool flag) |
FILE * | getFILE () |
There are two constructors to a file stream: (1) provide a FILE pointer to an existing file, or (2) provide a file name and let FileStream open the object. By default, FileStream calls fclose() on the file only for case (2). This default behavior can be changed by making a call to closeFileOnExit().
SAMRAI::tbox::FileStream::FileStream | ( | const char * | filename, | |
const StreamMode | mode | |||
) |
Open a file with the specified filename and the stream mode. The mode can be either FileStream::Read, FileStream::Write, or FileStream::Append. If the filename cannot be opened, then the program aborts with an error. By default, the filename will be closed when the destructor for FileStream is called.
SAMRAI::tbox::FileStream::FileStream | ( | FILE * | file, | |
const StreamMode | mode | |||
) |
Use an existing file for the XDR stream. The stream mode can be either FileStream::Read or FileStream::Write. The append mode is treated as a write. By default, the file is NOT closed when the destructor for FileStream is called.
SAMRAI::tbox::FileStream::~FileStream | ( | ) | [virtual] |
The virtual destructor for a file stream. This optionally closes the file depending on the status of the closeFileOnExit() flag.
void SAMRAI::tbox::FileStream::closeFileOnExit | ( | const bool | flag | ) | [inline] |
Flag to close or not close the file when the file streamfinishes. The default value for this flag is true if the filename constructor is used but false if the FILE constructor is used.
FILE * SAMRAI::tbox::FileStream::getFILE | ( | ) | [inline] |
Return the FILE data structure corresponding to the file stream.