FileBuffer

Class for reading data from a file, uses PhysFS http://physfs.icculus.org and is capable of reading from archives on the search path.

Summary
Class for reading data from a file, uses PhysFS http://physfs.icculus.org and is capable of reading from archives on the search path.
Initializes empty buffer.
Initializing constructor, calls open.
Destructor, calls close.
Loads a file into the FileBuffer.
Frees memory occupied by loaded data.
Loads an amount of data, returns a pointer to the loaded data.
Gets position of internal cursor inside data.
Gets size of data.
Checks if internal cursor is at end of file.
Checks if file is open.

(Con/ De)structors

FileBuffer

FileBuffer()

Initializes empty buffer.

FileBuffer

FileBuffer(const std::string &filename)

Initializing constructor, calls open.

Parameters

filenameName of file to load.

~FileBuffer

~FileBuffer()

Destructor, calls close.

General

open

void open(const std::string &filename)

Loads a file into the FileBuffer.

Parameters

filenameName of file to load.

close

void close()

Frees memory occupied by loaded data.

Accessors

getData

std::vector<ubyte> getData(int amount = )

Loads an amount of data, returns a pointer to the loaded data.  If the requested amount of data wasn’t available, returns only what could be loaded.  If amount is 0 (default), returns entire buffer.

Parameters

amountmaximum amount of data to load [default: 0]

Returns

Vector containing loaded data, empty if nothing loaded.

getPosition

uint getPosition() const

Gets position of internal cursor inside data.

Returns

Position of cursor reading in data.

getSize

uint getSize() const

Gets size of data.

Returns

Size of currently loaded data.

isEOF

bool isEOF() const

Checks if internal cursor is at end of file.

Returns

True iff eof, false otherwise.

isOpen

bool isOpen() const

Checks if file is open.

Returns

True iff file is open, false otherwise.

FileBuffer()
Initializes empty buffer.
void open(const std::string &filename)
Loads a file into the FileBuffer.
~FileBuffer()
Destructor, calls close.
void close()
Frees memory occupied by loaded data.
std::vector<ubyte> getData(int amount = )
Loads an amount of data, returns a pointer to the loaded data.
uint getPosition() const
Gets position of internal cursor inside data.
uint getSize() const
Gets size of data.
bool isEOF() const
Checks if internal cursor is at end of file.
bool isOpen() const
Checks if file is open.