c2ephp

FileReader Class Reference

Wrapper class to make reading files easier. More...

Inheritance diagram for FileReader:
Collaboration diagram for FileReader:

List of all members.

Public Member Functions

 FileReader ($filename)
 Instantiates a filereader for the given file, ready for reading.
 Read ($count)
 Reads a string.
 ReadInt ($count)
 Reads an integer.
 GetPosition ()
 Gets the position of the cursor.
 GetSubString ($start, $length=FALSE)
 Gets a substring.
 ReadCString ()
 Reads a c-style string at the current position.
 Seek ($position)
 Changes the current position in the reader's stream.
 Skip ($count)
 Advances the position of the reader by $count.

Detailed Description

Wrapper class to make reading files easier.

Quite often you'll have to make a FileReader in order to use other read from a file.
This is a simple process, simply pass in the filename to FileReader()

Definition at line 9 of file FileReader.php.


Member Function Documentation

FileReader::FileReader ( filename)

Instantiates a filereader for the given file, ready for reading.

Parameters:
$filenameA full path to the file you want to open.

Definition at line 22 of file FileReader.php.

FileReader::GetPosition ( )

Gets the position of the cursor.

This is analagous to ftell in C or PHP.

Implements IReader.

Definition at line 55 of file FileReader.php.

FileReader::GetSubString ( start,
length = FALSE 
)

Gets a substring.

This function is to allow things like PRAYFile to pull out a big chunk of data and then initialise a new StringReader to deal with it. It's not the most efficient way of doing things memory-wise, but it simplifies the code and c2e files don't tend to get big enough to make this inefficiency a concern on any reasonably modern hardware.

Implements IReader.

Definition at line 60 of file FileReader.php.

FileReader::Read ( length)

Reads a string.

Parameters:
$lengthLength of the string to read in bytes

Implements IReader.

Definition at line 34 of file FileReader.php.

FileReader::ReadCString ( )

Reads a c-style string at the current position.

C-style means that the string is terminated by a NUL (0) character.

Implements IReader.

Definition at line 78 of file FileReader.php.

FileReader::ReadInt ( length)

Reads an integer.

Parameters:
$lengthLength of the integer in bytes.

Implements IReader.

Definition at line 42 of file FileReader.php.

FileReader::Seek ( position)

Changes the current position in the reader's stream.

This is analagous to fseek in C or PHP.

Implements IReader.

Definition at line 88 of file FileReader.php.

FileReader::Skip ( count)

Advances the position of the reader by $count.

Implements IReader.

Definition at line 93 of file FileReader.php.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations