#include <LDK/PhysFSFile.h>
Inheritance diagram for LDK::PhysFSFile:
Public Member Functions | |
PhysFSFile (PHYSFS_file *file=NULL) | |
virtual void | openRead (const char *fileName, bool text=false) |
virtual void | openWrite (const char *fileName, bool text=false) |
virtual void | openAppend (const char *fileName, bool text=false) |
virtual int64 | length () |
virtual void | close () |
virtual bool | eof () |
virtual int64 | tell () |
virtual int64 | seek (int64 offset, int whence) |
virtual void | flush () |
PHYSFS_file * | handle () |
virtual int64 | read (void *buffer, uint32 objCount, uint32 objSize=1) |
virtual int32 | getc () |
virtual int32 | ungetc (char c) |
virtual const char * | gets (char *buffer, uint32 size) |
virtual int64 | write (const void *buffer, uint32 objCount, uint32 objSize=1) |
virtual int32 | putc (char c) |
virtual int32 | puts (const char *str) |
virtual int32 | printf (const char *format,...) |
virtual int32 | vprintf (const char *format, va_list ap) |
Protected Member Functions | |
void | resetPos () |
Protected Attributes | |
PHYSFS_file * | mFile |
int | mUnget |
int64 | mPos |
Supports large files (> 4 gigabytes) on 32-bit architectures, but some archive formats (like ZIP) have their own limits.
Cannot write archive files, only reads them. Writing is always to a native file.
The physfs library is available from http://www.icculus.org/physfs
Read it's documentation for more info.
Definition at line 65 of file PhysFSFile.h.
virtual void LDK::PhysFSFile::openRead | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for reading. Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual void LDK::PhysFSFile::openWrite | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for writing. Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual void LDK::PhysFSFile::openAppend | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for appending (writing at the end). Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual int64 LDK::PhysFSFile::length | ( | ) | [virtual] |
Gets the length of the file in bytes. Use with care in text mode, as may not take into account strange line terminations like on windows.
Implements LDK::VFile.
virtual void LDK::PhysFSFile::close | ( | ) | [virtual] |
Close this file.
Implements LDK::VFile.
virtual bool LDK::PhysFSFile::eof | ( | ) | [virtual] |
Test for end of file condition.
Implements LDK::VFile.
virtual int64 LDK::PhysFSFile::tell | ( | ) | [virtual] |
Determine the current file position.
IOError | if the file handle is invalid or an error occurred. |
Implements LDK::VFile.
virtual int64 LDK::PhysFSFile::seek | ( | int64 | offset, | |
int | whence | |||
) | [virtual] |
Seek to a new position within this file.
offset | The distance to seek. | |
whence | May be SEEK_CUR (seek from current pos) or SEEK_END (seek from the end of the file). Anything else means seek from the beginning. |
IOError | If the file handle is invalid or an error occurred. | |
EofError | On an attempt to seek past the start or end of the file. |
Implements LDK::VFile.
virtual void LDK::PhysFSFile::flush | ( | ) | [virtual] |
Flush any buffers associated with this file.
IOError | if the file handle is invalid or an error occurred. |
Implements LDK::VFile.
virtual int64 LDK::PhysFSFile::read | ( | void * | buffer, | |
uint32 | objCount, | |||
uint32 | objSize = 1 | |||
) | [virtual] |
Read a number of objects from this file.
buffer | The buffer to store read data into. | |
objCount | The number of objects to read. | |
objSize | The size in bytes of each object. |
IOError | If the file handle is invalid or the file is not readable. | |
ArgumentError | If objCount or objSize is 0. | |
EofError | On an attempt to read past the end of the file. |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::getc | ( | ) | [virtual] |
Read a single character (byte) from this file. Mostly used in text mode.
IOError | if the file handle is invalid or the file is not readable. | |
EofError | On an attempt to read past the end of the file. |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::ungetc | ( | char | c | ) | [virtual] |
Push one character back into the stream. Mostly used in text mode for programming language lexers and parsers. Character is lost by seeking or flushing, and only one character may be held in the pushed back buffer at a time.
c | The character to push back. |
IOError | If the file handle is invalid or the file is not readable. | |
EofError | If the file position is at the beginning of the file. |
Implements LDK::VFile.
virtual const char* LDK::PhysFSFile::gets | ( | char * | buffer, | |
uint32 | size | |||
) | [virtual] |
Read at most 1 less than size characters into buffer
buffer | The buffer to store read data into. | |
size | The size of the buffer in characters. |
IOError | If the file handle is invalid or the file is not readable. | |
EofError | If the file ends before whitespace or size-1 characters. |
Implements LDK::VFile.
virtual int64 LDK::PhysFSFile::write | ( | const void * | buffer, | |
uint32 | objCount, | |||
uint32 | objSize = 1 | |||
) | [virtual] |
Write a number of objects to this file.
buffer | The buffer that holds the data to be written. | |
objCount | The number of objects to be written. | |
objSize | The size of each object to be written. |
IOError | If the file handle is invalid, the file is not writable, or the requested number of objects written does not match the actual number of objects written. | |
ArgumentError | If ObjCount or ObjSize are 0. |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::putc | ( | char | c | ) | [virtual] |
Write a single character to this file.
c | The character to write. |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::puts | ( | const char * | str | ) | [virtual] |
Write a string to this file. Behaves like "fputs" i.e. no newline is appended.
str | The string to write. |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::printf | ( | const char * | format, | |
... | ||||
) | [virtual] |
Produce output according to format, as described in your compiler/OS documentation.
format | the format string | |
... | The data to format |
Implements LDK::VFile.
virtual int32 LDK::PhysFSFile::vprintf | ( | const char * | format, | |
va_list | ap | |||
) | [virtual] |
Produce output according to format, as described in your compiler/OS documentation.
format | the format string | |
ap | A variable length argument list containing the data to format. |
Implements LDK::VFile.