Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# File Class Reference

This class provides basic file input/output capabilies. More...

`#include <File.h>`

List of all members.

## Public Member Functions
| File (const char *name, const char *mode)
| Constructor.
| ~File ()
| Destructor.
void | read (void *p, unsigned size)
| The function read a number of bytes from the file to a certain memory location.
void | write (const void *p, unsigned size)
| The function writes a number of bytes from a certain memory location into the file.
void | printf (const char *format,...)
| The function implements printf for the stream represented by instances of this class.
bool | exists () const
| The function returns whether the file represented by an object of this class actually exists.
bool | eof () const
| The function returns whether the end of the file represented by an object of this class was reached.
## Static Public Member Functions
char * | getGTDir ()
| The function returns the current GT directory, e.g.
## Private Attributes
OFS::FILE * | stream
| File handle.
char | buf [65536]
| A buffer to reduce the number of operation system calls.
unsigned int | bufSize
| The number of bytes in the buffer while reading.
unsigned int | index
| The next byte in the buffer to read/write.
bool | isWrite
| Is this a write stream?

## Detailed Description

This class provides basic file input/output capabilies.

Definition at line 20 of file File.h.

## Constructor & Destructor Documentation

File::File | ( | const char * | name,
|  | const char * | mode
| ) |

  | Constructor. Parameters:
  name | File name or path. If it is a relative path, it is assumed to be relative to the path for configuration files. Otherwise, the path is used directly.
  mode | File open mode as used by fopen defined in stdio.h.
Definition at line 14 of file File.cpp. References ASSERT, buf, bufSize, getGTDir(), index, isWrite, and stream.

Here is the call graph for this function:

File::~File | ( |  | ) |

| Destructor. Definition at line 32 of file File.cpp. References buf, index, isWrite, stream, and VERIFY.

## Member Function Documentation

void File::read | ( | void * | p,
|  | unsigned | size
| ) |

  | The function read a number of bytes from the file to a certain memory location. Parameters:
  p | The start of the memory space the data is written to.
  size | The number of bytes read from the file.
Definition at line 42 of file File.cpp. References ASSERT, buf, bufSize, index, isWrite, and stream. Referenced by InFile::readFromStream().

void File::write | ( | const void * | p,
|  | unsigned | size
| ) |

  | The function writes a number of bytes from a certain memory location into the file. Parameters:
  p | The start of the memory space the data is read from.
  size | The number of bytes written into the file.
Definition at line 60 of file File.cpp. References buf, index, stream, and VERIFY. Referenced by OutFile::writeToStream().

void File::printf | ( | const char * | format,
|  | ... |
| ) |

  | The function implements printf for the stream represented by instances of this class. Parameters:
  format | Format string as used by printf defined in stdio.h.
  ... | See printf in stdio.h.
Definition at line 74 of file File.cpp. References ASSERT, index, and stream.

bool File::exists | ( |  | ) | const`[inline]`

| The function returns whether the file represented by an object of this class actually exists. Returns: The existence of the file. Definition at line 72 of file File.h. References stream. Referenced by OutFile::exists(), and InFile::exists().

bool File::eof | ( |  | ) | const

| The function returns whether the end of the file represented by an object of this class was reached. Returns: End of file reached? Definition at line 83 of file File.cpp. References bufSize, index, and stream. Referenced by InFile::getEof().

char * File::getGTDir | ( |  | ) | `[static]`

| The function returns the current GT directory, e.g. /MS/OPENR/APP or <...>/GT2003 or /usr/local/GT2003 Returns: The current GTDir Definition at line 92 of file File.cpp. Referenced by File().

## Member Data Documentation

OFS::FILE* File::stream`[private]`

| File handle. Definition at line 23 of file File.h. Referenced by eof(), exists(), File(), printf(), read(), write(), and ~File().

char File::buf[65536]`[private]`

| A buffer to reduce the number of operation system calls. Definition at line 24 of file File.h. Referenced by File(), read(), write(), and ~File().

unsigned int File::bufSize`[private]`

| The number of bytes in the buffer while reading. Definition at line 25 of file File.h. Referenced by eof(), File(), and read().

unsigned int File::index`[private]`

| The next byte in the buffer to read/write. Definition at line 25 of file File.h. Referenced by eof(), File(), printf(), read(), write(), and ~File().

bool File::isWrite`[private]`

| Is this a write stream? Definition at line 27 of file File.h. Referenced by File(), read(), and ~File().

The documentation for this class was generated from the following files:

- Platform/Aperios1.3.2/File.h
- Platform/Aperios1.3.2/File.cpp