back to index
File
- used to access real local file systems
- transparent byte order conversion
- uses the ANSI-C <stdio.h> file functions
- also see the PakFile class which can transparently map logic file names to either local files or data sections in a pakfile.
Inheritance
Object -> Stream -> File
Properties
byteOrder - readwrite, BIG_ENDIAN or LITTLE_ENDIAN
object - readwrite,
offset - readwrite
size - read
i8 - read/write byte from/to stream
i16 - read/write word from/to stream
i32 - read/write dword from/to stream
f32 - read/write floating point number from/to stream
f64 - convert float<->double
Constants
SEEK_BEG, SEEK_CUR, SEEK_END - arguments to seek()
ERRINVALIDSEEK, ERRIO, ERRCREATEFILE, ERROPENFILE - error codes
IOS_OUT, IOS_IN, IOS_INOUT - arguments to openLocal()
Methods
close () - close file previously opened by open() or openTemp(). temp files will not be removed automatically
deserialize (Object _o, int _rtti) - deserialize object from stream (optional typeinfo)
int eof () - test if end of file has been reached
flush () - flush filebuffers (i.e. finish writes)
int getByteOrder () - return current filestream byteorder (BIG_ENDIAN/LITTLE_ENDIAN)
int getErrorCode () - if file is open, this will return the last error
String getErrorStringByCode (int _code) - if file is open, this is used to convert an error code to a string.
int getI8 () - read a byte
int getI16 () - read 16bit integer, fix byteorder, expand sign
int getI32 () - read 32bit integer, fix byteorder
float getF32 () - read a 32bit floating point value
float getF64 () - read a 64bit floating point value ("double"), downcast to 32bit
getObject (Object _o) - deserialize object from stream (no typeinfo)
int getOffset () - return current read/write offset
int getSize () - return file size.
int isOpen () - test if file is open
setI8 (int _i) - write a byte.
setI16 (int _i) - write a 16bit short. convert to stream byteorder.
setI32 (int _i) - write a 32bit long. convert to stream byteorder.
setF32 (float _f) - write a 32bit floating point value
setF64 (float _f) - write a 32bit floating point value ("double"), expand to 64bit
int open (String _name, int _iosmode) - open a local file, _iosmode must be one of IOS_IN, IOS_OUT, IOS_INOUT.
String openTemp (String _directory, String _prefix) - make temp file and return its name
int readBuffer (Buffer _b, int _off, int _num, int _resize) - read _num bytes from stream and store in buffer at offset _off. resize buffer if _resize==true.
int readString (String _s, int _num) - read max _num chars from stream (resp. until ASCIIZ)
removeTemp () - remove temp file previously opened by openTemp()
seek (int _mode, int _off) - adjust read/write offset
serialize (Object _o, int _rtti) - serialize object to stream (optional typeinfo)
setByteOrder (int _order) - BIG_ENDIAN or LITTLE_ENDIAN
setObject (Object _o) - serialize object to stream (without typeinfo)
setOffset (int _off) - like seek(SEEK_BEG, _off)
int writeBuffer (Buffer _b, int _off, int _num) - write _num bytes to stream
int writeString (String _s, int _off, int _num) - write _num chars to stream
Example
testfileio.tks
3ds.tks
md2.tks
back to index