Open Source Cross-Platform Game Programming

UserData

This library's API roughly matches the API of the FileIO library. Provides basic functions for interacting with the local user-persisted-and-sandboxed file system. Generally each platform provides a directory or some data store that is persisted just for the current user or app session. For Windows, this is the app's directory under %APPDATA%. For OSX and linux, this is the app's .-prefixed directory under ~/. For JavaScript, this library will create a virtual file system that is persisted over the localStorage object. All operations are virtualized and sandboxed over this directory, treating it as an empty file system.

function currentDirectory()[link]

Returns the root of the virtualized sandboxed file system. This is actually a hard coded string and returns a '/' every time.

function directoryCreate(path, makeParents)[link]

Creates a new directory

Arguments

NameTypeOptionalDescription
path string

an absolute or relative path to create

makeParents boolean Optional

true if parent directories should be created if already not present

function directoryDelete(path)[link]

Deletes a directory

Arguments

NameTypeDescription
path string

an absolute or relative path of a directory to delete

function directoryExists(path)[link]

Checks to see if a directory exists.

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
boolean

True if the path exists and is a directory (not a file).

function directoryList(path, includeFullPath)[link]

Returns a list of files and subdirectories in a given directory

Arguments

NameTypeOptionalDescription
path string

an absolute or relative path

includeFullPath boolean Optional

true if absolute file paths should be returned. Otherwise, file names only are returned.

Return Value

TypeDescription
List of strings

list of files

function directoryMove(pathFrom, pathTo)[link]

Moves a directory and its contents to a new location.

Arguments

NameTypeDescription
pathFrom string

an absolute or relative path of a directory to move

pathTo string

an absolute or relative path of a location to move a directory to

function fileCopy(pathFrom, pathTo, allowOverwrite)[link]

Copies a file to a new location. Optionally allows overwriting files.

Arguments

NameTypeOptionalDescription
pathFrom string

an absolute or relative path of the original file location

pathTo string

an absolute or relative path of the new file location

allowOverwrite boolean Optional

true if overwriting existing files is okay

function fileDelete(path)[link]

Deletes a file from disk

Arguments

NameTypeDescription
path string

an absolute or relative path

function fileExists(path)[link]

Checks to see if a file exists.

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
boolean

True if the path exists and is a file (not a directory).

function fileMove(pathFrom, pathTo, allowOverwrite)[link]

Moves a file from one location to a new one. Optionally allows overwriting files.

Arguments

NameTypeOptionalDescription
pathFrom string

an absolute or relative path of the original file location

pathTo string

an absolute or relative path of the new file location

allowOverwrite boolean Optional

true if overwriting existing files is okay

function fileReadBytes(path)[link]

Returns a list of bytes in the file. These are unsigned numbers from 0 to 255.

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
List of integers

List of bytes

function fileReadLines(path)[link]

Returns a list of lines in the file as a list of strings

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
List of strings

List of lines in the file

function fileReadText(path)[link]

Returns the file contents as a string

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
string

file contents as a string

function fileWriteBytes(path, bytes)[link]

Writes binary content to a file. Input must be a list of byte values that are either signed or unsigned.

Arguments

NameTypeDescription
path string

an absolute or relative path

bytes List of integers

List of bytes

function fileWriteText(path, content, encoding)[link]

Writes text to a file

Arguments

NameTypeOptionalDescription
path string

an absolute or relative path

content string

content to write to a file as a string

encoding FileIO.TextEncoding Optional

encoding to use

function getPathInfo(path)[link]

Returns a file descriptor.

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
FileIOCommon.FileDescriptor

File properties

function pathExists(path)[link]

Checks to see if a path exists (either a file or a directory).

Arguments

NameTypeDescription
path string

an absolute or relative path

Return Value

TypeDescription
boolean

True if the path exists.

function pathJoin(parts)[link]

Joins a list of strings with the platform's default path delimiter.

Arguments

NameTypeDescription
parts List of strings

strings to join