#include <Flek/FFile.H>
fFile provides efficient file io routines in a c++ encapsulation. On most systems it should perform better than c++ io streams. Ultimately, this class should be similar to Ruby's File Class.
FFile::FFile(char *filename=0, FFileMode mode=FFileRead);
The Constructor.Parameters
filename The name of the file to open. mode The mode the file should be opened in:
- FFileRead - Open text file for reading. The stream is positioned at the beginning of the file.
- FFileReadPlus - Open for reading and writing. The stream is positioned at the beginning of the file.
- FFileWrite - Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.
- FFileWritePlus - Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file.
- FFileAppend - Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file.
- FFileAppendPlus - Open for reading and writing. The file is created if it does not exist. The stream is positioned at the end of the file.
*
bool FFile::bad();
Report if there has been any errors.
void FFile::close();
Close the file stream.
FILE *FFile::fd();
Return the C file handle.
void FFile::get_hi(uchar& r);
Get a single unsigned character from the file stream using Hi (MSB) byte order.void FFile::get_hi(short& r);
Get a single short int from the file stream using Hi (MSB) byte order.void FFile::get_hi(ushort& r);
Get a single unsigned short int from the file stream using Hi (MSB) byte order.void FFile::get_hi(ulong& r);
Get a single unsigned long int from the file stream using Hi (MSB) byte order.
void FFile::open(char *filename, FFileMode mode);
Open a file with the given filename, and a mode. The mode should be one of the standard fopen modes (see the constructor for a listing).
inline void FFile::put_hi(char c);
Put a single character into the file stream using Hi (MSB) byte order.inline void FFile::put_hi(uchar c);
Put a single unsigned character into the file stream using Hi (MSB) byte order.inline void FFile::put_hi(unsigned short c);
Put a single unsigned short into the file stream using Hi (MSB) byte order.inline void FFile::put_hi(short c);
Put a single unsigned short into the file stream using Hi (MSB) byte order.inline void FFile::put_hi(unsigned long c);
Put a single unsigned long into the file stream using Hi (MSB) byte order.inline void FFile::put_hi(long c);
Put a single long into the file stream using Hi (MSB) byte order.
inline void FFile::read(char *c, int len);
Read an array of characters into the file stream.inline void FFile::read(uchar *c, int len);
Read an array of unsigned characters into the file stream.
inline void FFile::seek(long pos, int mode = SEEK_SET);
Set the file postion indicator to pos. Seek can set pos relative to the beginning (mode=SEEK_SET), the end (mode=SEEK_END), or the current position (mode=SEEK_CUR).
long FFile::tell();
Report the current file position.
inline void FFile::write(char *c, int len);
Write an array of characters into the file stream.
FFile::~FFile();
The destructor closes the file if it is still open.