BinaryMachines
Info
Dependencies:
- None
Implementation:
BinaryMachines.d on GitHub
This package allows you to create and write your own files anywhere in the file system.
Initialization
N/A
BinaryWriter
BW_NewFile
BW_NewFile
Creates the file with the file
name and opens a stream. Doesn't work if a stream is already open.
var string file
Name of created file
Return value
The function returns TRUE
if the file is successfully created and initialized, FALSE
is returned otherwise.
BW_Close
BW
BW
Writes length
bytes from the data
to the stream, maximum 4 bytes.
var int data
Value of bytesvar int length
Number of bytes
BW_Int
BW_Int
Writes 4 bytes from the data
to the stream. Same as BW(data, 4)
.
var int data
Integer value to write
BW_Char
BW_Char
Writes the first character from the data
to the stream. Same as BW(Str_GetCharAt(data, 0), 1)
.
var string data
Char to write
BW_String
BW_String
Writes the data
terminated with \0
to the stream.
var string data
String to write
BW_Byte
BW_Byte
Writes a byte from the data
to the stream. Same as BW(data, 1)
.
var int data
Byte value to write
BW_Bytes
BW_Bytes
Writes length
of bytes from the pointer dataPtr
to the stream.
var int dataPtr
Pointer of data to writevar int length
Number of bytes
BW_Text
BW_Text
Writes the string to the stream without terminating it. So it can no longer be read.
var string data
Text to write
BW_NextLine
BinaryReader
BR_OpenFile
BR_OpenFile
Opens the file with the file
name and opens a stream. Doesn't work if a stream is already open.
var string file
File to be opened
Return value
The function returns TRUE
if the file is successfully opened and initialized, FALSE
is returned otherwise.
BR_Close
BR
BR
Reads bytes from the stream.
var int length
Number of bytes to read (maximum 4)
Return value
The function returns the value of read bytes.
BR_Int
BR_Int
Reads 4 bytes from the stream. Same as BR(4)
.
The function returns the read integer.
BR_Char
BR_Char
Reads a character from the stream. Same as BR(1)
.
The function returns the read character as a string
.
BR_String
BR_String
Reads a string terminated by \0
from the stream.
The function returns the read string.
BR_Byte
BR_Byte
Reads a byte from the stream.
The function returns the read byte.
BR_Bytes
BR_Bytes
Reads bytes from the stream.
var int length
Number of bytes to read
Return value
The function returns a pointer to the read bytes.
BR_TextLine
BR_TextLine
Reads a line from the stream.
The function returns the read line.
BR_Text
BR_Text
Reads a string of the given length from a stream.
var int length
Number of characters to read
Return value
The function returns the read string.
BR_NextLine
Enginecalls
WIN_GetLastError
WIN_GetLastError
Call of a Win32 API GetLastError
function
The function returns calling thread's last-error code.
WIN_CreateFile
WIN_CreateFile
Call of a Win32 API CreateFileA
function
Full description of parameters can be found here
Return value
Information about return value can be found here
WIN_WriteFile
WIN_WriteFile
Call of a Win32 API WriteFile
function
Full description of parameters can be found here
WIN_ReadFile
WIN_ReadFile
Call of a Win32 API ReadFile
function
Full description of parameters can be found here
WIN_CloseHandle
WIN_CloseHandle
Call of a Win32 API CloseHandle
function
Full description of parameters can be found here
WIN_GetFileSize
WIN_GetFileSize
Call of a Win32 API GetFileSize
function
Full description of parameters can be found here
Return value
Information about return value can be found here
Constants
In addition there are some constants defined for use with the specific engine calls.
Examples
Save and load variables
Congratulate the player
The location of an NPCs
Note
Examples originally written by Gottfried and posted on World of Gothic forum.