|
Torque2D Reference
|
#include <platformFileIO.h>
Public Types | |
| enum | Status { Ok = 0 , IOError , EOS , IllegalCall , Closed , UnknownError } |
| What is the status of our file handle? More... | |
| enum | AccessMode { Read = 0 , Write = 1 , ReadWrite = 2 , WriteAppend = 3 } |
| How are we accessing the file? More... | |
| enum | Capability { FileRead = BIT(0) , FileWrite = BIT(1) } |
| Flags used to indicate what we can do to the file. More... | |
Public Member Functions | |
| File () | |
| Default constructor. | |
| virtual | ~File () |
| Destructor. | |
| Status | open (const char *filename, const AccessMode openMode) |
| U32 | getPosition () const |
| Status | setPosition (S32 position, bool absolutePos=true) |
| U32 | getSize () const |
| Returns the size of the file. | |
| Status | flush () |
| Status | close () |
| Status | getStatus () const |
| Gets the status of the file. | |
| Status | read (U32 size, char *dst, U32 *bytesRead=NULL) |
| Status | write (U32 size, const char *src, U32 *bytesWritten=NULL) |
| bool | hasCapability (Capability cap) const |
| Returns whether or not this file is capable of the given function. | |
Protected Member Functions | |
| Status | setStatus () |
| Called after error encountered. | |
| Status | setStatus (Status status) |
| Setter for the current status. | |
| enum AccessMode |
| enum Capability |
| enum Status |
What is the status of our file handle?
| Enumerator | |
|---|---|
| Ok | Ok! |
| IOError | Read or Write error. |
| EOS | End of Stream reached (mostly for reads) |
| IllegalCall | An unsupported operation used. Always accompanied by AssertWarn. |
| Closed | Tried to operate on a closed stream (or detached filter) |
| UnknownError | Catchall. |
| File | ( | ) |
Default constructor.
|
virtual |
Destructor.
| File::Status close | ( | ) |
Closes the file
| File::Status flush | ( | ) |
Make sure everything that's supposed to be written to the file gets written.
| U32 getPosition | ( | ) | const |
Gets the current position in the file
This is in bytes from the beginning of the file.
| U32 getSize | ( | ) | const |
Returns the size of the file.
| File::Status getStatus | ( | ) | const |
Gets the status of the file.
| bool hasCapability | ( | Capability | cap | ) | const |
Returns whether or not this file is capable of the given function.
| File::Status open | ( | const char * | filename, |
| const AccessMode | openMode | ||
| ) |
Opens a file for access using the specified AccessMode
| File::Status read | ( | U32 | size, |
| char * | dst, | ||
| U32 * | bytesRead = NULL |
||
| ) |
Reads "size" bytes from the file, and dumps data into "dst". The number of actual bytes read is returned in bytesRead
| File::Status setPosition | ( | S32 | position, |
| bool | absolutePos = true |
||
| ) |
Sets the current position in the file.
You can set either a relative or absolute position to go to in the file.
|
protected |
Called after error encountered.
|
protected |
Setter for the current status.
| File::Status write | ( | U32 | size, |
| const char * | src, | ||
| U32 * | bytesWritten = NULL |
||
| ) |
Writes "size" bytes into the file from the pointer "src". The number of actual bytes written is returned in bytesWritten