c2ephp
|
Wrapper class to make reading files easier. More...
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. |
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.
FileReader::FileReader | ( | $ | filename | ) |
Instantiates a filereader for the given file, ready for reading.
$filename | A 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.
$length | Length 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.
$length | Length 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.