Skip to content

Filesystem

Functions to read and write files in the plugin folder. Every path is relative to the folder of the plugin, the one with its manifest.json.

Functions

Function Returns Description
Balltze.filesystem.createDirectory(path) boolean Creates a folder and its parents. Returns true when it created the folder and false when it already existed.
Balltze.filesystem.removeDirectory(path) boolean Removes a folder and everything in it. Returns whether it succeeded.
Balltze.filesystem.listDirectory(path) string[] or false Names of the entries of a folder. Folder names end with \. Returns false when the path is not a folder.
Balltze.filesystem.directoryExists(path) boolean Whether the folder exists.
Balltze.filesystem.writeFile(path, data, append) boolean Writes data to a file, replacing it, or adding to its end when append is true. Returns whether it succeeded.
Balltze.filesystem.readFile(path) string or nil Contents of a file, or nil when it cannot be opened.
Balltze.filesystem.deleteFile(path) boolean Deletes a file. Returns whether a file was deleted.
Balltze.filesystem.fileExists(path) boolean Whether the file exists.
Balltze.filesystem.getPluginPath() string Full path of the plugin folder.
Balltze.filesystem.getGamePath() string Full path of the game's working folder, normally the game folder.
Balltze.filesystem.getProfilesPath() string Full path of the active player profile, or an empty string when there is none.

Example

Balltze.filesystem.createDirectory("logs")
Balltze.filesystem.writeFile("logs\\kills.log", "first blood\n", true)

for _, entry in ipairs(Balltze.filesystem.listDirectory("logs")) do
    Balltze.logger.info("Found {}", entry)
end