Module

fileio

File-IO functions.

Members

# inner FILE

file mode definition.

Properties:
Name Type Description
READ *

open file in read mode.

WRITE *

open file in write mode (truncating existing contents)

APPEND *

open file in append mode.

# inner SEEK

file seek definition.

Properties:
Name Type Description
SET *

the offset is relative to the start of the file.

CUR *

the offset is relative to the the current position indicator.

END *

the offset is relative to the end-of-file.

# inner ZIPFILE

ZIP file mode definition.

Properties:
Name Type Description
READ *

open ZIP file in read mode.

WRITE *

open ZIP file in write mode (truncating existing contents)

APPEND *

open ZIP file in append mode.

DELETE *

open ZIP file in delete mode.

Methods

# inner BytesToString(data) → {string}

Convert byte array to ASCII string. The string is terminated at the first NULL byte or at array length (whichever comes first).

Parameters:
Name Type Description
data Array.<number>

array of numbers.

a string.

string

# inner DirExists(dirname) → {boolean}

check for existence of a directory.

Parameters:
Name Type Description
dirname string

name of directory to check.

true if the directory exists, else false.

boolean

# inner FileExists(filename) → {boolean}

check for existence of a file.

Parameters:
Name Type Description
filename string

name of file to check.

true if the file exists, else false.

boolean

# inner FreeSpace(drvNum) → {FreeInfo}

Get free space info on drive.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

drive space info object.

FreeInfo

# inner Gc(info)

Run garbage collector, print statistics to logfile if 'info==true'.

Parameters:
Name Type Description
info boolean

true to print collection stats to logfile.

# inner GetDrive()

This function determine the current default drive. This is a wrapper for DOS IN21, ah=0Eh.

the current default drive (1=A:, 2=B:, etc.).

# inner GetFSType(drvNum) → {string}

determine file system type.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

file system type.

string

# inner GetFramerate() → {number}

Current frame rate.

current framerate.

number

# inner GetParallelPorts() → {Array.<number>}

get available parallel ports.

list of available parallel ports and their addresses.

Array.<number>

# inner GetSerialPorts() → {Array.<number>}

get available serial ports.

list of available serial ports and their addresses.

Array.<number>

# inner InPortByte(port) → {number}

read a byte value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

8-bit value read from port.

number

# inner InPortLong(port) → {number}

read a long value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

32-bit value read from port.

number

# inner InPortWord(port) → {number}

read a word value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

16-bit value read from port.

number

# inner IsCDROM(drvNum) → {boolean}

Check if drive is a CD-ROM.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a CD-ROM, else false.

boolean

# inner IsFAT32(drvNum) → {boolean}

Check if drive was formated with FAT32.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a FAT32 volume, else false.

boolean

# inner IsFixed(drvNum) → {boolean}

Check if drive is a fixed drive.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a fixed drive, else false.

boolean

# inner IsRAMDisk(drvNum) → {boolean}

Check if drive is a RAM disk.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a RAM disk, else false.

boolean

# inner KeyIsPressed(key) → {boolean}

Check if key with keycode from KEY is pressed.

Parameters:
Name Type Description
key number

the key to check

tru if the key is currently pressed, else false.

boolean

# inner List(dname) → {Array.<string>}

Get directory listing.

Parameters:
Name Type Description
dname string

name of directory to list.

Throws an error if listing fails.

array of entry names.

Array.<string>

# inner MakeDir(name)

make a directory.

Parameters:
Name Type Description
name string

path/name of the new directory

# inner MemoryInfo() → {MemInfo}

Get information system memory.

an info object.

MemInfo

# inner NamedFunction(p, s, fopt)

parse a string into a function. Works like Function() by a source file name can be provided.

Parameters:
Name Type Attributes Description
p string

name of the single parameter.

s string

the source of the function.

f string <optional>

an optional filename where the source came from.

# inner OutPortByte(port, value)

write a byte value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

8-bit value to write to port.

# inner OutPortLong(port, value)

write a long value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

32-bit value to write to port.

# inner OutPortWord(port, value)

write a word value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

16-bit value to write to port.

# inner Read(filename) → {string}

Load the contents of a file into a string. Throws exception if loading fails.

Parameters:
Name Type Description
filename string

name of file to read.

Throws an error if reading fails.

the contents of the file.

string

# inner ReadZIP(filename, entryname) → {string}

Load the contents of a ZIP file entry into a string. Throws exception if loading fails.

Parameters:
Name Type Description
filename string

name of file to read.

entryname string

name of entry in the ZIP file to read.

Throws an error if reading fails.

the contents of the file.

string

# inner RealPath(path)

This function canonicalizes the input path. The path is canonicialized by removing consecutive and trailing slashes, making the path absolute if it's relative by prepending the current drive letter and working directory, removing "." components, collapsing ".." components, adding a drive specifier if needed, and converting all slashes to '/'. DOS-style 8+3 names of directories which are part of the pathname, as well as its final filename part, are returned lower-cased, but long filenames are left intact.

Parameters:
Name Type Description
path string

a path.

# inner Rename(from, to)

rename file/directory.

Parameters:
Name Type Description
from string

old name

to string

new name

# inner RmDir(name)

remove a directory (must be empty).

Parameters:
Name Type Description
name string

path/name of the directory.

# inner RmFile(name)

remove a file.

Parameters:
Name Type Description
name string

path/name of the file.

# inner SetDrive(drive)

This function set the current default drive based on drive (1=A:, 2=B:, etc.) and determines the number of available logical drives. This is a wrapper for DOS IN21, ah=19h.

Parameters:
Name Type Description
drive number

the new default drive.

the number of available logical drives.

# inner SetExitKey(key)

Change the exit key from ESCAPE to any other keycode from KEY.

Parameters:
Name Type Description
key number

the new exit key

# inner SetExitMessage(msg)

set a console message to display at shutdown of DOjS.

Parameters:
Name Type Description
msg string

the message.

# inner SetFramerate(rate)

Set maximum frame rate. If Loop takes longer than '1/rate' seconds then the framerate will not be reached.

Parameters:
Name Type Description
rate number

max frame rate wanted.

# inner Stat(name) → {StatInfo}

Get information about a file / directory.

Parameters:
Name Type Description
name string

name of the file to get info for.

Throws an error if stat fails.

an info object.

StatInfo

# inner StringToBytes(str) → {Array.<number>}

Convert ASCII string to byte array.

Parameters:
Name Type Description
str string

string to convert.

array of numbers.

Array.<number>

# inner System(cmd, flags) → {number}

Run a DOS command.

Parameters:
Name Type Description
cmd string

the command to execute with its parameters.

flags SYSTEM

flags indicating which subsystems to shutdown (if any) during execution of cmd.

the return code of the command.

number

File-IO functions.

Members

# inner FILE

file mode definition.

Properties:
Name Type Description
READ *

open file in read mode.

WRITE *

open file in write mode (truncating existing contents)

APPEND *

open file in append mode.

# inner SEEK

file seek definition.

Properties:
Name Type Description
SET *

the offset is relative to the start of the file.

CUR *

the offset is relative to the the current position indicator.

END *

the offset is relative to the end-of-file.

# inner ZIPFILE

ZIP file mode definition.

Properties:
Name Type Description
READ *

open ZIP file in read mode.

WRITE *

open ZIP file in write mode (truncating existing contents)

APPEND *

open ZIP file in append mode.

DELETE *

open ZIP file in delete mode.

Methods

# inner BytesToString(data) → {string}

Convert byte array to ASCII string. The string is terminated at the first NULL byte or at array length (whichever comes first).

Parameters:
Name Type Description
data Array.<number>

array of numbers.

a string.

string

# inner DirExists(dirname) → {boolean}

check for existence of a directory.

Parameters:
Name Type Description
dirname string

name of directory to check.

true if the directory exists, else false.

boolean

# inner FileExists(filename) → {boolean}

check for existence of a file.

Parameters:
Name Type Description
filename string

name of file to check.

true if the file exists, else false.

boolean

# inner FreeSpace(drvNum) → {FreeInfo}

Get free space info on drive.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

drive space info object.

FreeInfo

# inner Gc(info)

Run garbage collector, print statistics to logfile if 'info==true'.

Parameters:
Name Type Description
info boolean

true to print collection stats to logfile.

# inner GetDrive()

This function determine the current default drive. This is a wrapper for DOS IN21, ah=0Eh.

the current default drive (1=A:, 2=B:, etc.).

# inner GetFSType(drvNum) → {string}

determine file system type.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

file system type.

string

# inner GetFramerate() → {number}

Current frame rate.

current framerate.

number

# inner GetParallelPorts() → {Array.<number>}

get available parallel ports.

list of available parallel ports and their addresses.

Array.<number>

# inner GetSerialPorts() → {Array.<number>}

get available serial ports.

list of available serial ports and their addresses.

Array.<number>

# inner InPortByte(port) → {number}

read a byte value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

8-bit value read from port.

number

# inner InPortLong(port) → {number}

read a long value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

32-bit value read from port.

number

# inner InPortWord(port) → {number}

read a word value from a hardware io-port.

Parameters:
Name Type Description
port number

port address to read from.

16-bit value read from port.

number

# inner IsCDROM(drvNum) → {boolean}

Check if drive is a CD-ROM.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a CD-ROM, else false.

boolean

# inner IsFAT32(drvNum) → {boolean}

Check if drive was formated with FAT32.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a FAT32 volume, else false.

boolean

# inner IsFixed(drvNum) → {boolean}

Check if drive is a fixed drive.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a fixed drive, else false.

boolean

# inner IsRAMDisk(drvNum) → {boolean}

Check if drive is a RAM disk.

Parameters:
Name Type Description
drvNum number

Number of the drive (0=default, 1=A:, 2 == B:, etc).

true if this is a RAM disk, else false.

boolean

# inner KeyIsPressed(key) → {boolean}

Check if key with keycode from KEY is pressed.

Parameters:
Name Type Description
key number

the key to check

tru if the key is currently pressed, else false.

boolean

# inner List(dname) → {Array.<string>}

Get directory listing.

Parameters:
Name Type Description
dname string

name of directory to list.

Throws an error if listing fails.

array of entry names.

Array.<string>

# inner MakeDir(name)

make a directory.

Parameters:
Name Type Description
name string

path/name of the new directory

# inner MemoryInfo() → {MemInfo}

Get information system memory.

an info object.

MemInfo

# inner NamedFunction(p, s, fopt)

parse a string into a function. Works like Function() by a source file name can be provided.

Parameters:
Name Type Attributes Description
p string

name of the single parameter.

s string

the source of the function.

f string <optional>

an optional filename where the source came from.

# inner OutPortByte(port, value)

write a byte value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

8-bit value to write to port.

# inner OutPortLong(port, value)

write a long value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

32-bit value to write to port.

# inner OutPortWord(port, value)

write a word value to a hardware io-port.

Parameters:
Name Type Description
port number

port address to write to.

value number

16-bit value to write to port.

# inner Read(filename) → {string}

Load the contents of a file into a string. Throws exception if loading fails.

Parameters:
Name Type Description
filename string

name of file to read.

Throws an error if reading fails.

the contents of the file.

string

# inner ReadZIP(filename, entryname) → {string}

Load the contents of a ZIP file entry into a string. Throws exception if loading fails.

Parameters:
Name Type Description
filename string

name of file to read.

entryname string

name of entry in the ZIP file to read.

Throws an error if reading fails.

the contents of the file.

string

# inner RealPath(path)

This function canonicalizes the input path. The path is canonicialized by removing consecutive and trailing slashes, making the path absolute if it's relative by prepending the current drive letter and working directory, removing "." components, collapsing ".." components, adding a drive specifier if needed, and converting all slashes to '/'. DOS-style 8+3 names of directories which are part of the pathname, as well as its final filename part, are returned lower-cased, but long filenames are left intact.

Parameters:
Name Type Description
path string

a path.

# inner Rename(from, to)

rename file/directory.

Parameters:
Name Type Description
from string

old name

to string

new name

# inner RmDir(name)

remove a directory (must be empty).

Parameters:
Name Type Description
name string

path/name of the directory.

# inner RmFile(name)

remove a file.

Parameters:
Name Type Description
name string

path/name of the file.

# inner SetDrive(drive)

This function set the current default drive based on drive (1=A:, 2=B:, etc.) and determines the number of available logical drives. This is a wrapper for DOS IN21, ah=19h.

Parameters:
Name Type Description
drive number

the new default drive.

the number of available logical drives.

# inner SetExitKey(key)

Change the exit key from ESCAPE to any other keycode from KEY.

Parameters:
Name Type Description
key number

the new exit key

# inner SetExitMessage(msg)

set a console message to display at shutdown of DOjS.

Parameters:
Name Type Description
msg string

the message.

# inner SetFramerate(rate)

Set maximum frame rate. If Loop takes longer than '1/rate' seconds then the framerate will not be reached.

Parameters:
Name Type Description
rate number

max frame rate wanted.

# inner Stat(name) → {StatInfo}

Get information about a file / directory.

Parameters:
Name Type Description
name string

name of the file to get info for.

Throws an error if stat fails.

an info object.

StatInfo

# inner StringToBytes(str) → {Array.<number>}

Convert ASCII string to byte array.

Parameters:
Name Type Description
str string

string to convert.

array of numbers.

Array.<number>

# inner System(cmd, flags) → {number}

Run a DOS command.

Parameters:
Name Type Description
cmd string

the command to execute with its parameters.

flags SYSTEM

flags indicating which subsystems to shutdown (if any) during execution of cmd.

the return code of the command.

number