Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GFile Class Reference

Represents a block of data. More...

#include <gauge3d/files/file.h>

Inherits GAUGE3D::GObject.

Inherited by GAUGE3D::GDiskFile, and GAUGE3D::GStringFile.

List of all members.

Public Types

typedef GSmartPointer<FileMappFileMap
enum  tMapFlags { READ = 1 << 0, WRITE = 1 << 1 }
 Flags for mapping a file to memory. More...


Public Methods

virtual ~GFile ()
virtual int Size ()=0
 Gets the size of the file in bytes.

virtual bool Truncate ()=0
 Truncates the file to zero length. Returns false if file was not writable.

pGIStream GetInputStream ()
 Get a GIStream for the file. May be null if the file is not readable. More...

pGOStream GetOutputStream ()
 Get a GOStream for the file. May be null if the file is not readable. More...

virtual pGRawIStream GetRawInputStream ()=0
 Get a GRawIStream for the file. May be null if the file is not readable.

virtual pGRawOStream GetRawOutputStream ()=0
 Get a GRawOStream for the file. May be null if the file is not writeable.

virtual pFileMap Map (int offset,int size,int flags)=0
 Maps a portion of the file to memory. More...

pFileMap Map (int flags=READ)
 Maps the entire file to memory. More...

virtual GString MapToDisk ()=0
 Copies the file to a temporary file on disk, if it is not already on the disk. More...

virtual GString Name ()=0
 Get the name of the file. More...

virtual operator GString ()
 Create a string containing the complete file. More...


Detailed Description

Represents a block of data.

This could be a file on the disk, a file in a compressed archive, a file on an ftp server, etc.


Member Enumeration Documentation

enum GAUGE3D::GFile::tMapFlags
 

Flags for mapping a file to memory.

Enumeration values:
READ   Make the map readable.
WRITE   Make it writable.


Member Function Documentation

pGIStream GAUGE3D::GFile::GetInputStream ( ) [inline]
 

Get a GIStream for the file. May be null if the file is not readable.

Remarks:
This just calls GetRawInputStream() and wraps a GIStream around it.

pGOStream GAUGE3D::GFile::GetOutputStream ( ) [inline]
 

Get a GOStream for the file. May be null if the file is not readable.

Remarks:
This just calls GetRawOutputStream() and wraps a GOStream around it.

pFileMap GAUGE3D::GFile::Map ( int offset,
int size,
int flags ) [pure virtual]
 

Maps a portion of the file to memory.

Parameters:
offset   Where to start the map relative to the beginning of the file.
size   How many bytes to map to memory.
flags   One or more of tMapFlags, bitwise or'd.
Returns:
A pointer to a FileMap class describing the map, or NULL if the file could not be mapped.

Reimplemented in GAUGE3D::GDiskFile, and GAUGE3D::GStringFile.

pFileMap GAUGE3D::GFile::Map ( int flags = READ ) [inline]
 

Maps the entire file to memory.

Parameters:
flags   One or more of tMapFlags, bitwise or'd.
Returns:
A pointer to a FileMap class describing the map, or NULL if the file could not be mapped.

GString GAUGE3D::GFile::MapToDisk ( ) [pure virtual]
 

Copies the file to a temporary file on disk, if it is not already on the disk.

Returns:
The path and name of the file on disk.

You should not write to the file on disk as other parts of the engine may be reading from it as well. The file on disk will be deleted when the GFile that created it is deleted (unless the file was on the disk to begin with).

Remarks:
Do not use this if you can avoid it. It is mainly meant for use with GLibrary, which must load shared libraries from disk due to the limitations of the library loading functions of every operating system I know of.

Reimplemented in GAUGE3D::GDiskFile, and GAUGE3D::GStringFile.

GString GAUGE3D::GFile::Name ( ) [pure virtual]
 

Get the name of the file.

Note:
This is not always the same as the name of the directory entry that points to the file, especially if the file is in a virtual filesystem.

Reimplemented in GAUGE3D::GDiskFile, and GAUGE3D::GStringFile.

GAUGE3D::GFile::operator GString ( ) [virtual]
 

Create a string containing the complete file.

Remarks:
This function pretty much just calls Map and makes a string out of the results. Do not use this on large files. Note that derived classes may define their own implementation of this, but they are not required to.

Reimplemented in GAUGE3D::GStringFile.


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:34 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000