Drag[en]gine Script Module DragonScript
1.23
|
Memory file. More...
Public Member Functions | |
Constructors | |
MemoryFile | new (String filename) |
Create memory file. More... | |
MemoryFile | new (MemoryFile memoryFile) |
Create copy of memory file. More... | |
Management | |
String | getFilename () |
File name. More... | |
int | getSize () |
Data size in bytes. More... | |
void | setSize (int size) |
Set data size in bytes. More... | |
FileReader | getReader () |
Get new FileReader starting reading at the start of the data. More... | |
FileWriter | getWriter (bool append) |
Get new FileWriter. More... | |
FileReader | getReaderZCompressed () |
Get new FileReader starting reading at the start of the data. More... | |
FileWriter | getWriterZCompressed () |
Get new FileWriter. More... | |
Memory file.
Stores byte string data in memory allowing FileReader and FileWriter to be used to read and write the data.
This is a native class.
String Dragengine.MemoryFile.getFilename | ( | ) |
File name.
FileReader Dragengine.MemoryFile.getReader | ( | ) |
Get new FileReader starting reading at the start of the data.
Multiple file readers can be active on the same memory file at different read positions. If the data is changed while file readers are using this memory file the next read calls can cause exceptions due to reading past the end of file.
FileReader Dragengine.MemoryFile.getReaderZCompressed | ( | ) |
Get new FileReader starting reading at the start of the data.
Same as getReader() but decompressed data using Z-Compression.
int Dragengine.MemoryFile.getSize | ( | ) |
Data size in bytes.
FileWriter Dragengine.MemoryFile.getWriter | ( | bool | append | ) |
Get new FileWriter.
Using multiple file writers is allowed but discouraged. Each writer maintain its own write position. If multiple writers attempt to write on the same memory file the data ist overwritten. If you need to use multiple file writers you have to manually move the write pointers to the right location.
If file readers are using this memory file while writers change the content the next read calls can cause exceptions due to reading past the end of file.
append | If true start writing at end of data. If false resizes data to 0 bytes and starts writing. |
FileWriter Dragengine.MemoryFile.getWriterZCompressed | ( | ) |
MemoryFile Dragengine.MemoryFile.new | ( | MemoryFile | memoryFile | ) |
Create copy of memory file.
memoryFile | Memory file to create copy of. |
MemoryFile Dragengine.MemoryFile.new | ( | String | filename | ) |
Create memory file.
filename | Filename shown if FileReader.getFilename() or FileWriter.getFilename() is called. |
void Dragengine.MemoryFile.setSize | ( | int | size | ) |
Set data size in bytes.
If size changes the data is undefined.