Main Page   Class Hierarchy   Compound List   File List   Compound Members  

TFile Class Reference

File access class. More...

#include <TFile.hh>

List of all members.

Public Types

enum  Seek { SET, CUR, END }
 Starting point used when seeking in file. More...


Public Methods

 TFile ()
 Default constructor.

 TFile (const TString &path, const TString &mode)
 Open the specified file.

 ~TFile ()
 Closes any open file.

void Close ()
 Close any open file.

bool GetMap (void *&start, long &length)
 Get address and length of mapped memory.

bool IsValid ()
 Query if a file is open.

long Length ()
 Return the current length of the file.

void * Map ()
 Map file into memory.

void * Map (long offset, long length)
 Map file into memory.

void UnMap ()
 Un map previously mapped memory.

bool Open (const TString &path, const TString &mode)
 Open the specified file.

TString Path ()
 Path name as recorded in the object regardless of its state.

long Read (void *buf, long count)
 Read bytes from file.

long Seek (long offset, enum Seek whence=SET)
 Seek in file.

void Sync ()
 Move all modified data and attributes of the file to the storage device.

bool Write (const TFile &file)
 Write other file to file.

bool Write (const TString &str)
 Write string to file.

long Write (const void *buf, long count)
 Write data to file.


Detailed Description

File access class.

FIXME: Add copy operator and reference counting.


Member Enumeration Documentation

enum TFile::Seek
 

Starting point used when seeking in file.

Enumeration values:
SET  Seek from begining.
CUR  Seek from current position.
END  Seek from end.


Constructor & Destructor Documentation

TFile::TFile const TString   path,
const TString   mode
 

Open the specified file.

Use IsValid() to check for validity.

Parameters:
path Path to file.
mode Mode can be one of the following, (r, r+, w, w+, a, a+) see manpage for fopen for more info.


Member Function Documentation

bool TFile::GetMap void *&    start,
long &    length
 

Get address and length of mapped memory.

Parameters:
start Start of mapped memory.
length Length of mapped memory.
Returns:
true, mapping exists or false, no mapping exists.

bool TFile::IsValid  
 

Query if a file is open.

Returns:
true, valid or false, not valid.

long TFile::Length  
 

Return the current length of the file.

Returns:
Length of file or -1 on failure.

void* TFile::Map long    offset,
long    length
 

Map file into memory.

Reading or writing past the current length of the file it not allowed. Also, mappging is only guaranteed to work if the file has been opened with read only or read and write permissions.

Parameters:
offset Offset into file to start map at.
lentgh Length of region of file to map.
Returns:
Ptr to mapped memory or NULL on failure.

void* TFile::Map  
 

Map file into memory.

Reading or writing past the current length of the file it not allowed. Also, mappging is only guaranteed to work if the file has been opened with read only or read and write permissions.

Returns:
Ptr to mapped memory or NULL on failure.

bool TFile::Open const TString   path,
const TString   mode
 

Open the specified file.

Parameters:
path Path to file.
mode Mode as passed to fopen().
Returns:
true, success or false, failure.

TString TFile::Path   [inline]
 

Path name as recorded in the object regardless of its state.

Returns:
Path name

long TFile::Read void *    buf,
long    count
 

Read bytes from file.

Parameters:
buf Buffer to put data in.
count Read this many bytes.
Returns:
Bytes read or -1 on failure.

long TFile::Seek long    offset,
enum Seek    whence = SET
 

Seek in file.

Parameters:
offset Seek this many bytes-
whence Starting position as in enum Seek.
Returns:
File position or -1 on seek error.

void TFile::Sync  
 

Move all modified data and attributes of the file to the storage device.

This call blocks until the operation is completed.

long TFile::Write const void *    buf,
long    count
 

Write data to file.

Parameters:
buf Ptr to source buffer.
count Number of bytes to write.
Returns:
Number of bytes written or -1 on failure.

bool TFile::Write const TString   str
 

Write string to file.

Parameters:
str String to write.
Returns:
true, success or false, failure.

bool TFile::Write const TFile &    file
 

Write other file to file.

The file position of file is not rewinded.

Parameters:
file File to write.
Returns:
true, success or false, failure.


The documentation for this class was generated from the following file:
Generated on Sat Feb 15 18:37:16 2003 for Tools by doxygen1.3-rc2