Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.FileReader Class Reference

File reader. More...

Inheritance diagram for Dragengine.FileReader:

Public Member Functions

Management
String getFilename ()
 File name.
int getLength ()
 File size in bytes.
int getPosition ()
 Current reading position in bytes from the beginning of the file.
void setPosition (int position)
 Set reading file position in bytes relative to beginning of file.
void movePosition (int offset)
 Move reading file position by offset in bytes.
void setPositionEnd (int position)
 Set reading file position in bytes relative to end of file.
int getStreamVersion ()
 Stream version used by readFromFile of native classes.
void setStreamVersion (int version)
 Set stream version used by readFromFile of native classes.
bool eof ()
 File reading pointer is at the end of file.
int readChar ()
 Read one byte (1 byte) and advance the file reading position.
int readByte ()
 Read one unsigned byte (1 byte) and advance the file reading position.
int readShort ()
 Read one short (2 bytes) and advance the file reading position.
int readUShort ()
 Read one unsigned short (2 bytes) and advance the file reading position.
int readInt ()
 Read one int (4 bytes) and advance the file reading position.
int readUInt ()
 Read one unsigned int (4 bytes) and advance the file reading position.
int readVarUInt ()
 Read variable length unsigned integer (1-4 bytes) and advances file pointer.
float readFloat ()
 Read one float (4 bytes) and advance the file reading position.
String readString8 ()
 Read string prefixed by a 1-byte length field and advance the file reading position.
String readString16 ()
 Read string prefixed by a 2-byte length field and advance the file reading position.
String readString32 ()
 Read string prefixed by a 4-byte length field and advance the file reading position.
String readVarString ()
 Read string prefixed by a 1-4 byte length field and advance the file reading position.
String readString (int size)
 Read string without length field and advance the file reading position.
void skipString8 ()
 Skips string prefixed by a 1-byte length field and advance the file reading position.
void skipString16 ()
 Skips string prefixed by a 2-byte length field and advance the file reading position.
void skipString32 ()
 Skips string prefixed by a 4-byte length field and advance the file reading position.
void skipVarString ()
 Skips string prefixed by a 1-4 byte length field and advance the file reading position.
TimeDate readTimeDate ()
 Read TimeDate instance.

Constructors

FileReader new (String filename)
 Create file reader reading from virtual file system file.
static FileReader newZCompressed (String filename)
 Create Z-Decompressing file reader reading from virtual file system file.

Detailed Description

File reader.

This is a native class.

Member Function Documentation

◆ eof()

bool Dragengine.FileReader.eof ( )

File reading pointer is at the end of file.

Referenced by readInt().

◆ getFilename()

String Dragengine.FileReader.getFilename ( )

File name.

Referenced by getLength().

◆ getLength()

int Dragengine.FileReader.getLength ( )

File size in bytes.

References getFilename().

Referenced by getPosition().

◆ getPosition()

int Dragengine.FileReader.getPosition ( )

Current reading position in bytes from the beginning of the file.

References getLength().

Referenced by movePosition().

◆ getStreamVersion()

int Dragengine.FileReader.getStreamVersion ( )

Stream version used by readFromFile of native classes.

References movePosition().

Referenced by readChar().

◆ movePosition()

void Dragengine.FileReader.movePosition ( int offset)

Move reading file position by offset in bytes.

References getPosition().

Referenced by getStreamVersion().

◆ new()

FileReader Dragengine.FileReader.new ( String filename)

Create file reader reading from virtual file system file.

References new().

Referenced by new().

◆ newZCompressed()

FileReader Dragengine.FileReader.newZCompressed ( String filename)
static

Create Z-Decompressing file reader reading from virtual file system file.

Version
1.8

References newZCompressed().

Referenced by newZCompressed().

◆ readByte()

int Dragengine.FileReader.readByte ( )

Read one unsigned byte (1 byte) and advance the file reading position.

Referenced by readUInt().

◆ readChar()

int Dragengine.FileReader.readChar ( )

Read one byte (1 byte) and advance the file reading position.

References getStreamVersion().

Referenced by readUInt().

◆ readFloat()

float Dragengine.FileReader.readFloat ( )

Read one float (4 bytes) and advance the file reading position.

References readUShort().

Referenced by skipString16().

◆ readInt()

int Dragengine.FileReader.readInt ( )

Read one int (4 bytes) and advance the file reading position.

References eof().

Referenced by readString8().

◆ readShort()

int Dragengine.FileReader.readShort ( )

Read one short (2 bytes) and advance the file reading position.

References setStreamVersion().

Referenced by readUInt().

◆ readString()

String Dragengine.FileReader.readString ( int size)

Read string without length field and advance the file reading position.

Referenced by readTimeDate().

◆ readString16()

String Dragengine.FileReader.readString16 ( )

Read string prefixed by a 2-byte length field and advance the file reading position.

References readUInt().

Referenced by skipVarString().

◆ readString32()

String Dragengine.FileReader.readString32 ( )

Read string prefixed by a 4-byte length field and advance the file reading position.

Version
1.22

Referenced by readTimeDate().

◆ readString8()

String Dragengine.FileReader.readString8 ( )

Read string prefixed by a 1-byte length field and advance the file reading position.

References readInt().

Referenced by skipString32().

◆ readTimeDate()

TimeDate Dragengine.FileReader.readTimeDate ( )

◆ readUInt()

int Dragengine.FileReader.readUInt ( )

Read one unsigned int (4 bytes) and advance the file reading position.

References readByte(), readChar(), and readShort().

Referenced by readString16().

◆ readUShort()

int Dragengine.FileReader.readUShort ( )

Read one unsigned short (2 bytes) and advance the file reading position.

Referenced by readFloat().

◆ readVarString()

String Dragengine.FileReader.readVarString ( )

Read string prefixed by a 1-4 byte length field and advance the file reading position.

Version
1.22

Referenced by readTimeDate().

◆ readVarUInt()

int Dragengine.FileReader.readVarUInt ( )

Read variable length unsigned integer (1-4 bytes) and advances file pointer.

Version
1.22

Variable length integers are written using 1 to 4 bytes. The highest 2 bits of the first byte stores the total length (0=1 byte, 1=2 bytes, 2=3 bytes, 3=4 bytes). The lower 6 bits are used as value. With each added byte the previous bits are shifted up. The maximum storable value is thus 1073741823.

Variable length unsigned integers are typically used for values like versions or revisions which start low and potentially grow large over time.

Referenced by skipString8().

◆ setPosition()

void Dragengine.FileReader.setPosition ( int position)

Set reading file position in bytes relative to beginning of file.

Referenced by setPositionEnd().

◆ setPositionEnd()

void Dragengine.FileReader.setPositionEnd ( int position)

Set reading file position in bytes relative to end of file.

References setPosition().

Referenced by setStreamVersion().

◆ setStreamVersion()

void Dragengine.FileReader.setStreamVersion ( int version)

Set stream version used by readFromFile of native classes.

References setPositionEnd().

Referenced by readShort().

◆ skipString16()

void Dragengine.FileReader.skipString16 ( )

Skips string prefixed by a 2-byte length field and advance the file reading position.

References readFloat().

Referenced by readTimeDate().

◆ skipString32()

void Dragengine.FileReader.skipString32 ( )

Skips string prefixed by a 4-byte length field and advance the file reading position.

Version
1.22

References readString8().

Referenced by readTimeDate().

◆ skipString8()

void Dragengine.FileReader.skipString8 ( )

Skips string prefixed by a 1-byte length field and advance the file reading position.

References readVarUInt().

Referenced by readTimeDate().

◆ skipVarString()

void Dragengine.FileReader.skipVarString ( )

Skips string prefixed by a 1-4 byte length field and advance the file reading position.

Version
1.22

References readString16().

Referenced by readTimeDate().


The documentation for this class was generated from the following file: