fileOpen
Shared
Opens a file that already exists, with the position at its start.
file|false fileOpen(string path [, bool readOnly = false])
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | The path. A path inside the calling resource, or @resource/path for another resource's file. Another resource's file only opens with readOnly. |
| readOnly | bool | If true, the file opens for reading only.default false |
Returns
The open file, or false if it does not exist, is a folder or could not be opened.
A path may not contain .., \ or :, nor start with /. Another resource's files can only be read; an invalid path logs a warning and the function returns false. The file is closed when the resource stops.
Example
local file = fileOpen("@maps/spawns.json", true)
if file then
local spawns = fromJSON(fileRead(file, fileGetSize(file)))
fileClose(file)
end